mirror of
https://github.com/tc39/test262.git
synced 2025-05-28 02:30:29 +02:00
Replace Temporal objects' .calendar getters with .calendarId/.getCalendar
This is the replacement of the old API with the new API. Semantics will be corrected in the following commit. Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
This commit is contained in:
parent
55fdf60820
commit
a1bf99771c
@ -76,7 +76,7 @@ var TemporalHelpers = {
|
||||
* Shorthand for asserting that each field of a Temporal.PlainDate is equal to
|
||||
* an expected value. (Except the `calendar` property, since callers may want
|
||||
* to assert either object equality with an object they put in there, or the
|
||||
* result of date.calendar.toString().)
|
||||
* value of date.calendarId.)
|
||||
*/
|
||||
assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) {
|
||||
assert(date instanceof Temporal.PlainDate, `${description} instanceof`);
|
||||
@ -94,7 +94,7 @@ var TemporalHelpers = {
|
||||
* Shorthand for asserting that each field of a Temporal.PlainDateTime is
|
||||
* equal to an expected value. (Except the `calendar` property, since callers
|
||||
* may want to assert either object equality with an object they put in there,
|
||||
* or the result of datetime.calendar.toString().)
|
||||
* or the value of datetime.calendarId.)
|
||||
*/
|
||||
assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) {
|
||||
assert(datetime instanceof Temporal.PlainDateTime, `${description} instanceof`);
|
||||
@ -117,13 +117,17 @@ var TemporalHelpers = {
|
||||
*
|
||||
* Shorthand for asserting that two Temporal.PlainDateTimes are of the correct
|
||||
* type, equal according to their equals() methods, and additionally that
|
||||
* their calendars are the same value.
|
||||
* their calendar internal slots are the same value.
|
||||
*/
|
||||
assertPlainDateTimesEqual(actual, expected, description = "") {
|
||||
assert(expected instanceof Temporal.PlainDateTime, `${description} expected value should be a Temporal.PlainDateTime`);
|
||||
assert(actual instanceof Temporal.PlainDateTime, `${description} instanceof`);
|
||||
assert(actual.equals(expected), `${description} equals method`);
|
||||
assert.sameValue(actual.calendar, expected.calendar, `${description} calendar same value`);
|
||||
assert.sameValue(
|
||||
actual.getISOFields().calendar,
|
||||
expected.getISOFields().calendar,
|
||||
`${description} calendar same value`
|
||||
);
|
||||
},
|
||||
|
||||
/*
|
||||
@ -132,7 +136,7 @@ var TemporalHelpers = {
|
||||
* Shorthand for asserting that each field of a Temporal.PlainMonthDay is
|
||||
* equal to an expected value. (Except the `calendar` property, since callers
|
||||
* may want to assert either object equality with an object they put in there,
|
||||
* or the result of monthDay.calendar.toString().)
|
||||
* or the value of monthDay.calendarId().)
|
||||
*/
|
||||
assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) {
|
||||
assert(monthDay instanceof Temporal.PlainMonthDay, `${description} instanceof`);
|
||||
@ -175,7 +179,7 @@ var TemporalHelpers = {
|
||||
* Shorthand for asserting that each field of a Temporal.PlainYearMonth is
|
||||
* equal to an expected value. (Except the `calendar` property, since callers
|
||||
* may want to assert either object equality with an object they put in there,
|
||||
* or the result of yearMonth.calendar.toString().)
|
||||
* or the value of yearMonth.calendarId.)
|
||||
*/
|
||||
assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) {
|
||||
assert(yearMonth instanceof Temporal.PlainYearMonth, `${description} instanceof`);
|
||||
@ -192,14 +196,18 @@ var TemporalHelpers = {
|
||||
*
|
||||
* Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct
|
||||
* type, equal according to their equals() methods, and additionally that
|
||||
* their time zones and calendars are the same value.
|
||||
* their time zones and calendar internal slots are the same value.
|
||||
*/
|
||||
assertZonedDateTimesEqual(actual, expected, description = "") {
|
||||
assert(expected instanceof Temporal.ZonedDateTime, `${description} expected value should be a Temporal.ZonedDateTime`);
|
||||
assert(actual instanceof Temporal.ZonedDateTime, `${description} instanceof`);
|
||||
assert(actual.equals(expected), `${description} equals method`);
|
||||
assert.sameValue(actual.timeZone, expected.timeZone, `${description} time zone same value`);
|
||||
assert.sameValue(actual.calendar, expected.calendar, `${description} calendar same value`);
|
||||
assert.sameValue(
|
||||
actual.getISOFields().calendar,
|
||||
expected.getISOFields().calendar,
|
||||
`${description} calendar same value`
|
||||
);
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = Temporal.Calendar.from(arg);
|
||||
assert.sameValue(result, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.id, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -42,5 +42,5 @@ const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
||||
const result = instance.dateFromFields(fields, options);
|
||||
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1, "date result");
|
||||
assert.sameValue(result.calendar, instance, "calendar result");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
|
@ -42,5 +42,5 @@ const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
||||
const result = instance.monthDayFromFields(fields, options);
|
||||
TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDay result");
|
||||
assert.sameValue(result.calendar, instance, "calendar result");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
|
@ -38,5 +38,5 @@ const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
||||
const result = instance.yearMonthFromFields(fields, options);
|
||||
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01", "yearMonth result");
|
||||
assert.sameValue(result.calendar, instance, "calendar result");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
|
@ -22,7 +22,7 @@ var cal = new class extends Temporal.Calendar {
|
||||
}("iso8601");
|
||||
|
||||
var relativeTo = new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, cal);
|
||||
assert.sameValue(relativeTo.calendar, cal);
|
||||
assert.sameValue(relativeTo.getCalendar(), cal);
|
||||
|
||||
var options = {
|
||||
smallestUnit: "days",
|
||||
|
@ -11,4 +11,4 @@ const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
|
||||
const arg = "iSo8601";
|
||||
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
const arg = 19761118;
|
||||
|
||||
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -20,7 +20,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -12,4 +12,4 @@ const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -33,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
|
||||
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
const arg = 19761118;
|
||||
|
||||
const result = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -18,7 +18,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = Temporal.Now.plainDate(arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -9,4 +9,4 @@ features: [Temporal]
|
||||
|
||||
const d = Temporal.Now.plainDateISO();
|
||||
assert(d instanceof Temporal.PlainDate);
|
||||
assert.sameValue(d.calendar.id, "iso8601");
|
||||
assert.sameValue(d.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
const arg = 19761118;
|
||||
|
||||
const result = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -18,7 +18,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = Temporal.Now.plainDateTime(arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -8,5 +8,4 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
const result = Temporal.Now.plainDateTimeISO();
|
||||
assert(result.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(result.calendar.id, "iso8601");
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
const arg = 19761118;
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -18,7 +18,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -6,7 +6,7 @@ esid: sec-temporal.now.zoneddatetime
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -10,7 +10,6 @@ features: [Temporal]
|
||||
const zdt = Temporal.Now.zonedDateTimeISO();
|
||||
const tz = Temporal.Now.timeZoneId();
|
||||
assert(zdt instanceof Temporal.ZonedDateTime);
|
||||
assert(zdt.calendar instanceof Temporal.Calendar);
|
||||
assert.sameValue(zdt.calendar.id, "iso8601");
|
||||
assert.sameValue(zdt.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert(zdt.timeZone instanceof Temporal.TimeZone);
|
||||
assert.sameValue(zdt.timeZone.id, tz);
|
||||
|
@ -17,9 +17,9 @@ Object.defineProperty(Temporal.Calendar, "from", {
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar);
|
||||
TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object");
|
||||
assert.sameValue(plainDateWithObject.calendar, calendar);
|
||||
assert.sameValue(plainDateWithObject.getCalendar(), calendar);
|
||||
|
||||
const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601");
|
||||
TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string");
|
||||
assert.sameValue(plainDateWithString.calendar.toString(), "iso8601");
|
||||
assert.notSameValue(plainDateWithString.calendar, calendar);
|
||||
assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
assert.notSameValue(plainDateWithString.getCalendar(), calendar);
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
const arg = 19761118;
|
||||
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ Object.defineProperty(Temporal.Calendar, "from", {
|
||||
});
|
||||
|
||||
const dateExplicit = new Temporal.PlainDate(...args, undefined);
|
||||
assert.sameValue(dateExplicit.calendar.toString(), "iso8601");
|
||||
assert.sameValue(dateExplicit.getISOFields().calendar, "iso8601", "calendar slot should store string");
|
||||
|
||||
const dateImplicit = new Temporal.PlainDate(...args);
|
||||
assert.sameValue(dateImplicit.calendar.toString(), "iso8601");
|
||||
assert.sameValue(dateImplicit.getISOFields().calendar, "iso8601", "calendar slot should store string");
|
||||
|
@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDate(
|
||||
"PlainDate is copied"
|
||||
);
|
||||
|
||||
assert.sameValue(result.calendar, orig.calendar, "Calendar is copied");
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
@ -17,5 +17,5 @@ features: [Temporal]
|
||||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => {
|
||||
const result = Temporal.PlainDate.from(datetime);
|
||||
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
|
||||
assert.sameValue(result.calendar, calendar, "calendar result");
|
||||
assert.sameValue(result.getCalendar(), calendar, "calendar result");
|
||||
});
|
||||
|
@ -11,4 +11,4 @@ features: [Temporal]
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const plainDate = Temporal.PlainDate.from({ year: 1976, month: 11, day: 18, calendar });
|
||||
TemporalHelpers.assertPlainDate(plainDate, 1976, 11, "M11", 18);
|
||||
assert.sameValue(plainDate.calendar, calendar);
|
||||
assert.sameValue(plainDate.getISOFields().calendar, "iso8601", "calendar slot should store a string");
|
||||
|
@ -19,7 +19,7 @@ TemporalHelpers.assertPlainDate(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
result.calendar,
|
||||
result.getCalendar(),
|
||||
calendar,
|
||||
"Calendar is copied"
|
||||
);
|
||||
|
@ -22,5 +22,5 @@ features: [Temporal]
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar");
|
||||
});
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plaindate.prototype.calendar
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const calendar = Object.getOwnPropertyDescriptor(Temporal.PlainDate.prototype, "calendar").get;
|
||||
|
||||
assert.sameValue(typeof calendar, "function");
|
||||
|
||||
assert.throws(TypeError, () => calendar.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => calendar.call(null), "null");
|
||||
assert.throws(TypeError, () => calendar.call(true), "true");
|
||||
assert.throws(TypeError, () => calendar.call(""), "empty string");
|
||||
assert.throws(TypeError, () => calendar.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => calendar.call(1), "1");
|
||||
assert.throws(TypeError, () => calendar.call({}), "plain object");
|
||||
assert.throws(TypeError, () => calendar.call(Temporal.PlainDate), "Temporal.PlainDate");
|
||||
assert.throws(TypeError, () => calendar.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype");
|
22
test/built-ins/Temporal/PlainDate/prototype/calendarId/branding.js
vendored
Normal file
22
test/built-ins/Temporal/PlainDate/prototype/calendarId/branding.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plaindate.prototype.calendarid
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const calendarId = Object.getOwnPropertyDescriptor(Temporal.PlainDate.prototype, "calendarId").get;
|
||||
|
||||
assert.sameValue(typeof calendarId, "function");
|
||||
|
||||
assert.throws(TypeError, () => calendarId.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => calendarId.call(null), "null");
|
||||
assert.throws(TypeError, () => calendarId.call(true), "true");
|
||||
assert.throws(TypeError, () => calendarId.call(""), "empty string");
|
||||
assert.throws(TypeError, () => calendarId.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => calendarId.call(1), "1");
|
||||
assert.throws(TypeError, () => calendarId.call({}), "plain object");
|
||||
assert.throws(TypeError, () => calendarId.call(Temporal.PlainDate), "Temporal.PlainDate");
|
||||
assert.throws(TypeError, () => calendarId.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype");
|
@ -2,12 +2,12 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plaindate.prototype.calendar
|
||||
description: The "calendar" property of Temporal.PlainDate.prototype
|
||||
esid: sec-get-temporal.plaindate.prototype.calendarid
|
||||
description: The "calendarId" property of Temporal.PlainDate.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.PlainDate.prototype, "calendar");
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.PlainDate.prototype, "calendarId");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
22
test/built-ins/Temporal/PlainDate/prototype/getCalendar/branding.js
vendored
Normal file
22
test/built-ins/Temporal/PlainDate/prototype/getCalendar/branding.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const getCalendar = Temporal.PlainDate.prototype.getCalendar;
|
||||
|
||||
assert.sameValue(typeof getCalendar, "function");
|
||||
|
||||
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => getCalendar.call(null), "null");
|
||||
assert.throws(TypeError, () => getCalendar.call(true), "true");
|
||||
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
|
||||
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => getCalendar.call(1), "1");
|
||||
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
|
||||
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate), "Temporal.PlainDate");
|
||||
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype");
|
33
test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js
vendored
Normal file
33
test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: >
|
||||
Tests that Temporal.PlainDate.prototype.getCalendar
|
||||
meets the requirements for built-in objects defined by the
|
||||
introduction of chapter 17 of the ECMAScript Language Specification.
|
||||
info: |
|
||||
Built-in functions that are not constructors do not have a "prototype" property unless
|
||||
otherwise specified in the description of a particular function.
|
||||
|
||||
Unless specified otherwise, a built-in object that is callable as a function is a built-in
|
||||
function object with the characteristics described in 10.3. Unless specified otherwise, the
|
||||
[[Extensible]] internal slot of a built-in object initially has the value true.
|
||||
|
||||
Unless otherwise specified every built-in function and every built-in constructor has the
|
||||
Function prototype object [...] as the value of its [[Prototype]] internal slot.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Temporal.PlainDate.prototype.getCalendar),
|
||||
true, "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Temporal.PlainDate.prototype.getCalendar),
|
||||
"[object Function]", "Object.prototype.toString");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Temporal.PlainDate.prototype.getCalendar),
|
||||
Function.prototype, "prototype");
|
||||
|
||||
assert.sameValue(Temporal.PlainDate.prototype.getCalendar.hasOwnProperty("prototype"),
|
||||
false, "prototype property");
|
25
test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js
vendored
Normal file
25
test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: Temporal.PlainDate.prototype.getCalendar.length is 0
|
||||
info: |
|
||||
Every built-in function object, including constructors, has a "length" property whose value is
|
||||
an integer. Unless otherwise specified, this value is equal to the largest number of named
|
||||
arguments shown in the subclause headings for the function description. Optional parameters
|
||||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
|
||||
«...name») are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the "length" property of a built-in function object has the
|
||||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.PlainDate.prototype.getCalendar, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
23
test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: Temporal.PlainDate.prototype.getCalendar.name is "getCalendar".
|
||||
info: |
|
||||
Every built-in function object, including constructors, that is not identified as an anonymous
|
||||
function has a "name" property whose value is a String. Unless otherwise specified, this value
|
||||
is the name that is given to the function in this specification.
|
||||
|
||||
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
|
||||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.PlainDate.prototype.getCalendar, "name", {
|
||||
value: "getCalendar",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
21
test/built-ins/Temporal/PlainDate/prototype/getCalendar/not-a-constructor.js
vendored
Normal file
21
test/built-ins/Temporal/PlainDate/prototype/getCalendar/not-a-constructor.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: >
|
||||
Temporal.PlainDate.prototype.getCalendar does not implement [[Construct]], is not new-able
|
||||
info: |
|
||||
Built-in function objects that are not identified as constructors do not implement the
|
||||
[[Construct]] internal method unless otherwise specified in the description of a particular
|
||||
function.
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.PlainDate.prototype.getCalendar();
|
||||
}, "Calling as constructor");
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.PlainDate.prototype.getCalendar), false,
|
||||
"isConstructor(Temporal.PlainDate.prototype.getCalendar)");
|
21
test/built-ins/Temporal/PlainDate/prototype/getCalendar/prop-desc.js
vendored
Normal file
21
test/built-ins/Temporal/PlainDate/prototype/getCalendar/prop-desc.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindate.prototype.getcalendar
|
||||
description: The "getCalendar" property of Temporal.PlainDate.prototype
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Temporal.PlainDate.prototype.getCalendar,
|
||||
"function",
|
||||
"`typeof PlainDate.prototype.getCalendar` is `function`"
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.PlainDate.prototype, "getCalendar", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -13,4 +13,4 @@ const result = date.getISOFields();
|
||||
assert.sameValue(result.isoYear, 2000, "isoYear result");
|
||||
assert.sameValue(result.isoMonth, 5, "isoMonth result");
|
||||
assert.sameValue(result.isoDay, 2, "isoDay result");
|
||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||
assert.sameValue(result.calendar, "iso8601", "calendar result");
|
||||
|
@ -11,4 +11,4 @@ features: [Temporal]
|
||||
const calendar = TemporalHelpers.calendarThrowEverything();
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const result = plainDate.toPlainDateTime("11:30:23");
|
||||
assert.sameValue(result.calendar, calendar, "calendar");
|
||||
assert.sameValue(result.getCalendar(), calendar, "calendar");
|
||||
|
@ -12,4 +12,4 @@ const calendar = new Temporal.Calendar("iso8601");
|
||||
const pd = new Temporal.PlainDate(1970, 12, 24, calendar);
|
||||
const pmd = pd.toPlainMonthDay();
|
||||
TemporalHelpers.assertPlainMonthDay(pmd, "M12", 24);
|
||||
assert.sameValue(pmd.calendar, calendar);
|
||||
assert.sameValue(pmd.getISOFields().calendar, "iso8601");
|
||||
|
@ -12,4 +12,4 @@ const calendar = new Temporal.Calendar("iso8601");
|
||||
const pd = new Temporal.PlainDate(1970, 12, 24, calendar);
|
||||
const pym = pd.toPlainYearMonth();
|
||||
TemporalHelpers.assertPlainYearMonth(pym, 1970, 12, "M12");
|
||||
assert.sameValue(pym.calendar, calendar);
|
||||
assert.sameValue(pym.getISOFields().calendar, "iso8601");
|
||||
|
@ -16,4 +16,4 @@ const result = plainDate.toZonedDateTime({
|
||||
});
|
||||
assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n);
|
||||
assert.sameValue(result.timeZone.toString(), "UTC");
|
||||
assert.sameValue(result.calendar, calendar);
|
||||
assert.sameValue(result.getCalendar(), calendar);
|
||||
|
@ -13,7 +13,7 @@ class CustomTimeZone extends Temporal.TimeZone {
|
||||
super("UTC");
|
||||
}
|
||||
getPossibleInstantsFor(plainDateTime) {
|
||||
assert.sameValue(plainDateTime.calendar, calendar);
|
||||
assert.sameValue(plainDateTime.getCalendar(), calendar);
|
||||
return [new Temporal.Instant(987654321_000_000_000n)];
|
||||
}
|
||||
}
|
||||
@ -25,4 +25,4 @@ const result = plainDate.toZonedDateTime({
|
||||
});
|
||||
assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n);
|
||||
assert.sameValue(result.timeZone, timeZone);
|
||||
assert.sameValue(result.calendar, calendar);
|
||||
assert.sameValue(result.getCalendar(), calendar);
|
||||
|
@ -14,15 +14,15 @@ const calendar = Temporal.Calendar.from("iso8601");
|
||||
const objectResult = plainDate.withCalendar(calendar);
|
||||
assert.notSameValue(objectResult, plainDate, "object: new object");
|
||||
TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object");
|
||||
assert.sameValue(objectResult.calendar, calendar, "object: calendar");
|
||||
assert.sameValue(objectResult.getCalendar(), calendar, "object: calendar");
|
||||
|
||||
const stringResult = plainDate.withCalendar("iso8601");
|
||||
assert.notSameValue(stringResult, plainDate, "string: new object");
|
||||
TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string");
|
||||
assert.sameValue(stringResult.calendar.id, "iso8601", "string: calendar");
|
||||
assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string");
|
||||
|
||||
const originalCalendar = plainDate.calendar;
|
||||
const originalCalendar = plainDate.getCalendar();
|
||||
const sameResult = plainDate.withCalendar(originalCalendar);
|
||||
assert.notSameValue(sameResult, plainDate, "original: new object");
|
||||
TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original");
|
||||
assert.sameValue(sameResult.calendar, originalCalendar, "original: calendar");
|
||||
assert.sameValue(sameResult.getCalendar(), originalCalendar, "original: calendar slot stores and object");
|
||||
|
@ -11,4 +11,4 @@ const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
|
||||
const arg = "iSo8601";
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
const arg = 19761118;
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = instance.withCalendar(arg);
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -20,7 +20,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = instance.withCalendar(arg);
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -12,4 +12,4 @@ const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -33,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
|
||||
const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -25,6 +25,6 @@ TemporalHelpers.checkSubclassingIgnored(
|
||||
[customCalendar],
|
||||
(result) => {
|
||||
TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5);
|
||||
assert.sameValue(result.calendar, customCalendar, "calendar result");
|
||||
assert.sameValue(result.getCalendar(), customCalendar, "calendar result");
|
||||
},
|
||||
);
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -10,7 +10,7 @@ features: [Temporal]
|
||||
const arg = 19761118;
|
||||
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -32,7 +32,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
});
|
||||
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ Object.defineProperty(Temporal.Calendar, "from", {
|
||||
});
|
||||
|
||||
const dateTimeExplicit = new Temporal.PlainDateTime(...dateTimeArgs, undefined);
|
||||
assert.sameValue(dateTimeExplicit.calendar.toString(), "iso8601");
|
||||
assert.sameValue(dateTimeExplicit.calendarId, "iso8601");
|
||||
|
||||
const dateTimeImplicit = new Temporal.PlainDateTime(...dateTimeArgs);
|
||||
assert.sameValue(dateTimeImplicit.calendar.toString(), "iso8601");
|
||||
assert.sameValue(dateTimeImplicit.calendarId, "iso8601");
|
||||
|
@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime(datetime,
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
datetime.calendar,
|
||||
datetime.getCalendar(),
|
||||
calendar,
|
||||
"calendar supplied in constructor can be extracted and is unchanged"
|
||||
);
|
||||
|
@ -17,5 +17,5 @@ features: [Temporal]
|
||||
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => {
|
||||
const result = Temporal.PlainDateTime.from(date);
|
||||
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed");
|
||||
assert.sameValue(result.calendar, calendar, "calendar result");
|
||||
assert.sameValue(result.getCalendar(), calendar, "calendar result");
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
"PlainDateTime is copied"
|
||||
);
|
||||
|
||||
assert.sameValue(result.calendar, orig.calendar, "Calendar is copied");
|
||||
assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied");
|
||||
|
||||
assert.notSameValue(
|
||||
result,
|
||||
|
@ -22,5 +22,5 @@ features: [Temporal]
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar");
|
||||
});
|
||||
|
@ -1,22 +0,0 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plaindatetime.prototype.calendar
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const calendar = Object.getOwnPropertyDescriptor(Temporal.PlainDateTime.prototype, "calendar").get;
|
||||
|
||||
assert.sameValue(typeof calendar, "function");
|
||||
|
||||
assert.throws(TypeError, () => calendar.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => calendar.call(null), "null");
|
||||
assert.throws(TypeError, () => calendar.call(true), "true");
|
||||
assert.throws(TypeError, () => calendar.call(""), "empty string");
|
||||
assert.throws(TypeError, () => calendar.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => calendar.call(1), "1");
|
||||
assert.throws(TypeError, () => calendar.call({}), "plain object");
|
||||
assert.throws(TypeError, () => calendar.call(Temporal.PlainDateTime), "Temporal.PlainDateTime");
|
||||
assert.throws(TypeError, () => calendar.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype");
|
22
test/built-ins/Temporal/PlainDateTime/prototype/calendarId/branding.js
vendored
Normal file
22
test/built-ins/Temporal/PlainDateTime/prototype/calendarId/branding.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plaindatetime.prototype.calendarid
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const calendarId = Object.getOwnPropertyDescriptor(Temporal.PlainDateTime.prototype, "calendarId").get;
|
||||
|
||||
assert.sameValue(typeof calendarId, "function");
|
||||
|
||||
assert.throws(TypeError, () => calendarId.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => calendarId.call(null), "null");
|
||||
assert.throws(TypeError, () => calendarId.call(true), "true");
|
||||
assert.throws(TypeError, () => calendarId.call(""), "empty string");
|
||||
assert.throws(TypeError, () => calendarId.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => calendarId.call(1), "1");
|
||||
assert.throws(TypeError, () => calendarId.call({}), "plain object");
|
||||
assert.throws(TypeError, () => calendarId.call(Temporal.PlainDateTime), "Temporal.PlainDateTime");
|
||||
assert.throws(TypeError, () => calendarId.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype");
|
@ -2,12 +2,12 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-temporal.plainyearmonth.prototype.calendar
|
||||
description: The "calendar" property of Temporal.PlainYearMonth.prototype
|
||||
esid: sec-get-temporal.plaindatetime.prototype.calendarid
|
||||
description: The "calendarId" property of Temporal.PlainDateTime.prototype
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.PlainYearMonth.prototype, "calendar");
|
||||
const descriptor = Object.getOwnPropertyDescriptor(Temporal.PlainDateTime.prototype, "calendarId");
|
||||
assert.sameValue(typeof descriptor.get, "function");
|
||||
assert.sameValue(descriptor.set, undefined);
|
||||
assert.sameValue(descriptor.enumerable, false);
|
22
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/branding.js
vendored
Normal file
22
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/branding.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: Throw a TypeError if the receiver is invalid
|
||||
features: [Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const getCalendar = Temporal.PlainDateTime.prototype.getCalendar;
|
||||
|
||||
assert.sameValue(typeof getCalendar, "function");
|
||||
|
||||
assert.throws(TypeError, () => getCalendar.call(undefined), "undefined");
|
||||
assert.throws(TypeError, () => getCalendar.call(null), "null");
|
||||
assert.throws(TypeError, () => getCalendar.call(true), "true");
|
||||
assert.throws(TypeError, () => getCalendar.call(""), "empty string");
|
||||
assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol");
|
||||
assert.throws(TypeError, () => getCalendar.call(1), "1");
|
||||
assert.throws(TypeError, () => getCalendar.call({}), "plain object");
|
||||
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime), "Temporal.PlainDateTime");
|
||||
assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype");
|
33
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/builtin.js
vendored
Normal file
33
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/builtin.js
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: >
|
||||
Tests that Temporal.PlainDateTime.prototype.getCalendar
|
||||
meets the requirements for built-in objects defined by the
|
||||
introduction of chapter 17 of the ECMAScript Language Specification.
|
||||
info: |
|
||||
Built-in functions that are not constructors do not have a "prototype" property unless
|
||||
otherwise specified in the description of a particular function.
|
||||
|
||||
Unless specified otherwise, a built-in object that is callable as a function is a built-in
|
||||
function object with the characteristics described in 10.3. Unless specified otherwise, the
|
||||
[[Extensible]] internal slot of a built-in object initially has the value true.
|
||||
|
||||
Unless otherwise specified every built-in function and every built-in constructor has the
|
||||
Function prototype object [...] as the value of its [[Prototype]] internal slot.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(Object.isExtensible(Temporal.PlainDateTime.prototype.getCalendar),
|
||||
true, "Built-in objects must be extensible.");
|
||||
|
||||
assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.getCalendar),
|
||||
"[object Function]", "Object.prototype.toString");
|
||||
|
||||
assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.getCalendar),
|
||||
Function.prototype, "prototype");
|
||||
|
||||
assert.sameValue(Temporal.PlainDateTime.prototype.getCalendar.hasOwnProperty("prototype"),
|
||||
false, "prototype property");
|
25
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/length.js
vendored
Normal file
25
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/length.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: Temporal.PlainDateTime.prototype.getCalendar.length is 0
|
||||
info: |
|
||||
Every built-in function object, including constructors, has a "length" property whose value is
|
||||
an integer. Unless otherwise specified, this value is equal to the largest number of named
|
||||
arguments shown in the subclause headings for the function description. Optional parameters
|
||||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
|
||||
«...name») are not included in the default argument count.
|
||||
|
||||
Unless otherwise specified, the "length" property of a built-in function object has the
|
||||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
23
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/name.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/name.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: Temporal.PlainDateTime.prototype.getCalendar.name is "getCalendar".
|
||||
info: |
|
||||
Every built-in function object, including constructors, that is not identified as an anonymous
|
||||
function has a "name" property whose value is a String. Unless otherwise specified, this value
|
||||
is the name that is given to the function in this specification.
|
||||
|
||||
Unless otherwise specified, the "name" property of a built-in function object, if it exists,
|
||||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "name", {
|
||||
value: "getCalendar",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
21
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/not-a-constructor.js
vendored
Normal file
21
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/not-a-constructor.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: >
|
||||
Temporal.PlainDateTime.prototype.getCalendar does not implement [[Construct]], is not new-able
|
||||
info: |
|
||||
Built-in function objects that are not identified as constructors do not implement the
|
||||
[[Construct]] internal method unless otherwise specified in the description of a particular
|
||||
function.
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.PlainDateTime.prototype.getCalendar();
|
||||
}, "Calling as constructor");
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.getCalendar), false,
|
||||
"isConstructor(Temporal.PlainDateTime.prototype.getCalendar)");
|
21
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/prop-desc.js
vendored
Normal file
21
test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/prop-desc.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.plaindatetime.prototype.getcalendar
|
||||
description: The "getCalendar" property of Temporal.PlainDateTime.prototype
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Temporal.PlainDateTime.prototype.getCalendar,
|
||||
"function",
|
||||
"`typeof PlainDateTime.prototype.getCalendar` is `function`"
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.PlainDateTime.prototype, "getCalendar", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
@ -19,4 +19,4 @@ assert.sameValue(result.isoSecond, 56, "isoSecond result");
|
||||
assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result");
|
||||
assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result");
|
||||
assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result");
|
||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||
assert.sameValue(result.calendar, "iso8601", "calendar result");
|
||||
|
@ -19,8 +19,8 @@ class Calendar extends Temporal.Calendar {
|
||||
}
|
||||
|
||||
dateUntil(d1, d2) {
|
||||
assert.sameValue(d1.calendar, this, "d1.calendar");
|
||||
assert.sameValue(d2.calendar, this, "d2.calendar");
|
||||
assert.sameValue(d1.getCalendar(), this, "d1.calendar");
|
||||
assert.sameValue(d2.getCalendar(), this, "d2.calendar");
|
||||
return new Temporal.Duration();
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ const dt = new Temporal.PlainDateTime(2020, 1, 1, 0, 0);
|
||||
const zdt = dt.toZonedDateTime("UTC");
|
||||
|
||||
assert.sameValue(zdt.epochNanoseconds, 1577836800000000000n, "nanoseconds");
|
||||
assert.sameValue(zdt.calendar.toString(), "iso8601", "calendar");
|
||||
assert.sameValue(zdt.calendarId, "iso8601", "calendar");
|
||||
assert.sameValue(zdt.timeZone.toString(), "UTC", "timezone");
|
||||
|
@ -40,6 +40,6 @@ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
||||
const result = dateTime.toZonedDateTime(timeZone, options);
|
||||
assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds);
|
||||
assert.sameValue(result.timeZone, timeZone);
|
||||
assert.sameValue(result.calendar, dateTime.calendar);
|
||||
|
||||
assert.compareArray(actual, expected);
|
||||
|
||||
assert.sameValue(result.getISOFields().calendar, dateTime.getISOFields().calendar);
|
||||
|
@ -19,8 +19,8 @@ class Calendar extends Temporal.Calendar {
|
||||
}
|
||||
|
||||
dateUntil(d1, d2) {
|
||||
assert.sameValue(d1.calendar, this, "d1.calendar");
|
||||
assert.sameValue(d2.calendar, this, "d2.calendar");
|
||||
assert.sameValue(d1.getCalendar(), this, "d1.calendar");
|
||||
assert.sameValue(d2.getCalendar(), this, "d2.calendar");
|
||||
return new Temporal.Duration();
|
||||
}
|
||||
}
|
||||
|
@ -19,4 +19,4 @@ TemporalHelpers.assertPlainDateTime(
|
||||
"works"
|
||||
);
|
||||
|
||||
assert.sameValue(result.calendar, calendar, "underlying calendar is unchanged");
|
||||
assert.sameValue(result.getCalendar(), calendar, "underlying calendar is unchanged");
|
||||
|
@ -11,4 +11,4 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
|
||||
|
||||
const arg = "iSo8601";
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
|
||||
const arg = 19761118;
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
assert.sameValue(result.calendarId, "iso8601", "19761118 is a valid ISO string for Calendar");
|
||||
|
||||
const numbers = [
|
||||
1,
|
||||
|
@ -12,7 +12,7 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
|
||||
let arg = "2016-12-31T23:59:60";
|
||||
const result1 = instance.withCalendar(arg);
|
||||
assert.sameValue(
|
||||
result1.calendar.id,
|
||||
result1.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar"
|
||||
);
|
||||
@ -20,7 +20,7 @@ assert.sameValue(
|
||||
arg = { calendar: "2016-12-31T23:59:60" };
|
||||
const result2 = instance.withCalendar(arg);
|
||||
assert.sameValue(
|
||||
result2.calendar.id,
|
||||
result2.calendarId,
|
||||
"iso8601",
|
||||
"leap second is a valid ISO string for Calendar (nested property)"
|
||||
);
|
||||
|
@ -12,4 +12,4 @@ const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456,
|
||||
const arg = "iso8601";
|
||||
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar.id, "iso8601", `Calendar created from string "${arg}"`);
|
||||
assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
|
||||
|
@ -33,7 +33,7 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { id: "replace-me" });
|
||||
const result = instance.withCalendar(arg);
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
||||
|
||||
assert.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -25,6 +25,6 @@ TemporalHelpers.checkSubclassingIgnored(
|
||||
[customCalendar],
|
||||
(result) => {
|
||||
TemporalHelpers.assertPlainDateTime(result, 1900, 2, "M02", 5, 12, 34, 56, 987, 654, 321);
|
||||
assert.sameValue(result.calendar, customCalendar, "calendar result");
|
||||
assert.sameValue(result.getCalendar(), customCalendar, "calendar result");
|
||||
},
|
||||
);
|
||||
|
@ -19,7 +19,7 @@ const cal = {
|
||||
day() { return 6; }
|
||||
};
|
||||
const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0);
|
||||
assert.sameValue(pdt.calendar.toString(), "iso8601", "PlainDateTime with ISO calendar");
|
||||
assert.sameValue(pdt.calendarId, "iso8601", "PlainDateTime with ISO calendar");
|
||||
const pd = new Temporal.PlainDate(2010, 11, 12, cal);
|
||||
const shifted = pdt.withPlainDate(pd);
|
||||
|
||||
@ -31,7 +31,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
shifted.calendar,
|
||||
shifted.getCalendar(),
|
||||
cal,
|
||||
"calendar is changed if receiver has ISO calendar (2)"
|
||||
);
|
||||
|
@ -33,7 +33,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
shifted.calendar,
|
||||
shifted.getCalendar(),
|
||||
cal2,
|
||||
"calendar is changed with same id (2)"
|
||||
);
|
||||
|
@ -34,7 +34,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
shifted.calendar,
|
||||
shifted.getCalendar(),
|
||||
cal,
|
||||
"calendar is unchanged with same calendars (2)"
|
||||
);
|
||||
|
@ -20,7 +20,7 @@ const cal = {
|
||||
};
|
||||
const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal);
|
||||
const pd = new Temporal.PlainDate(2010, 11, 12);
|
||||
assert.sameValue(pd.calendar.toString(), "iso8601", "PlainDate with ISO calendar");
|
||||
assert.sameValue(pd.calendarId, "iso8601", "PlainDate with ISO calendar");
|
||||
const shifted = pdt.withPlainDate(pd);
|
||||
|
||||
TemporalHelpers.assertPlainDateTime(
|
||||
@ -31,7 +31,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
shifted.calendar,
|
||||
shifted.getCalendar(),
|
||||
cal,
|
||||
"calendar is unchanged if input has ISO calendar (2)"
|
||||
);
|
||||
|
@ -29,7 +29,7 @@ TemporalHelpers.assertPlainDateTime(
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
shifted.calendar,
|
||||
shifted.getCalendar(),
|
||||
cal,
|
||||
"calendar is unchanged if input has ISO calendar (2)"
|
||||
);
|
||||
|
@ -24,5 +24,5 @@ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const datetime = new Temporal.PlainDateTime(2000, 5, 3, 13, 3, 27, 123, 456, 789);
|
||||
// the PlainDate's calendar will override the PlainDateTime's ISO calendar
|
||||
const result = datetime.withPlainDate({ year: 2001, month: 6, day: 4, calendar: temporalObject });
|
||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||
assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar");
|
||||
});
|
||||
|
@ -10,12 +10,12 @@ features: [Temporal]
|
||||
|
||||
const leapDay = new Temporal.PlainMonthDay(2, 29);
|
||||
TemporalHelpers.assertPlainMonthDay(leapDay, "M02", 29, "leap day is supported");
|
||||
assert.sameValue(leapDay.calendar.id, "iso8601", "leap day calendar");
|
||||
assert.sameValue(leapDay.calendarId, "iso8601", "leap day calendar");
|
||||
|
||||
const beforeEpoch = new Temporal.PlainMonthDay(12, 2, "iso8601", 1920);
|
||||
TemporalHelpers.assertPlainMonthDay(beforeEpoch, "M12", 2, "reference year before epoch", 1920);
|
||||
assert.sameValue(beforeEpoch.calendar.id, "iso8601", "reference year before epoch calendar");
|
||||
assert.sameValue(beforeEpoch.calendarId, "iso8601", "reference year before epoch calendar");
|
||||
|
||||
const afterEpoch = new Temporal.PlainMonthDay(1, 7, "iso8601", 1980);
|
||||
TemporalHelpers.assertPlainMonthDay(afterEpoch, "M01", 7, "reference year after epoch", 1980);
|
||||
assert.sameValue(afterEpoch.calendar.id, "iso8601", "reference year after epoch calendar");
|
||||
assert.sameValue(afterEpoch.calendarId, "iso8601", "reference year after epoch calendar");
|
||||
|
@ -10,4 +10,4 @@ features: [Temporal]
|
||||
const arg = "iSo8601";
|
||||
|
||||
const result = new Temporal.PlainMonthDay(12, 15, arg, 1972);
|
||||
assert.sameValue(result.calendar.id, "iso8601", "Calendar is case-insensitive");
|
||||
assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user