mirror of
https://github.com/tc39/test262.git
synced 2025-07-26 15:34:29 +02:00
Regularize some of the "calendar-temporal-object" tests
I used a script to "unroll" some of the calls to TemporalHelpers.checkToTemporalCalendarFastPath(), and rewrite it slightly not to use a specific Calendar instance. This is in preparation for a future refactor, but also allows testing the PlainTime path which was not previously covered. (I didn't unroll all the calls and remove the helper yet, because the remaining calls have custom assertions that I haven't gotten the script to work with yet. For the same reason, I didn't yet convert these to use the test generation facility. These will follow in a future PR.)
This commit is contained in:
parent
374aac475d
commit
a157570ddc
@ -5,16 +5,35 @@
|
|||||||
esid: sec-temporal.calendar.from
|
esid: sec-temporal.calendar.from
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.calendar.from step 1:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
1. Return ? ToTemporalCalendar(_item_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const newCalendar = Temporal.Calendar.from(temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
assert.sameValue(newCalendar, calendar, "calendar object retrieved from internal slot");
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = Temporal.Calendar.from(arg);
|
||||||
|
assert.sameValue(result, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,17 +5,36 @@
|
|||||||
esid: sec-temporal.instant.prototype.tozoneddatetime
|
esid: sec-temporal.instant.prototype.tozoneddatetime
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.instant.prototype.tozoneddatetime step 6:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
6. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const instant = new Temporal.Instant(1_000_000_000_987_654_321n);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const result = instant.toZonedDateTime({ timeZone: "UTC", calendar: temporalObject });
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.now.plaindate
|
esid: sec-temporal.now.plaindate
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.now.plaindate step 1:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
1. Let _dateTime_ be ? SystemDateTime(_temporalTimeZoneLike_, _calendar_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-systemdatetime step 3:
|
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = Temporal.Now.plainDate(temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = Temporal.Now.plainDate(arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.now.plaindatetime
|
esid: sec-temporal.now.plaindatetime
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.now.plaindatetime step 1:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
1. Return ? SystemDateTime(_temporalTimeZoneLike_, _calendar_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-systemdatetime step 3:
|
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal, arrow-function]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = Temporal.Now.plainDateTime(temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = Temporal.Now.plainDateTime(arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.now.zoneddatetime
|
esid: sec-temporal.now.zoneddatetime
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.now.zoneddatetime step 1:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
1. Return ? SystemZonedDateTime(_temporalTimeZoneLike_, _calendar_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-systemzoneddatetime step 3:
|
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = Temporal.Now.zonedDateTime(temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = Temporal.Now.zonedDateTime(arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.plaindate
|
esid: sec-temporal.plaindate
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plaindate step 5:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendarwithisodefault step 2:
|
|
||||||
2. Return ? ToTemporalCalendar(_temporalCalendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = new Temporal.PlainDate(2000, 5, 2, temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = new Temporal.PlainDate(2000, 5, 2, arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,17 +5,36 @@
|
|||||||
esid: sec-temporal.plaindate.prototype.withcalendar
|
esid: sec-temporal.plaindate.prototype.withcalendar
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plaindate.prototype.withcalendar step 3:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const result = plainDate.withCalendar(temporalObject);
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.plaindatetime
|
esid: sec-temporal.plaindatetime
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plaindatetime step 11:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
11. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendarwithisodefault step 2:
|
|
||||||
2. Return ? ToTemporalCalendar(_temporalCalendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
assert.sameValue(result.calendar, calendar, 'Temporal object coerced to calendar');
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,17 +5,36 @@
|
|||||||
esid: sec-temporal.plaindatetime.prototype.withcalendar
|
esid: sec-temporal.plaindatetime.prototype.withcalendar
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plaindatetime.prototype.withcalendar step 3:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const result = plainDateTime.withCalendar(temporalObject);
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.plainmonthday
|
esid: sec-temporal.plainmonthday
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plainmonthday step 5:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendarwithisodefault step 2:
|
|
||||||
2. Return ? ToTemporalCalendar(_temporalCalendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = new Temporal.PlainMonthDay(5, 2, temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = new Temporal.PlainMonthDay(12, 15, arg, 1972);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.plainyearmonth
|
esid: sec-temporal.plainyearmonth
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.plainyearmonth step 5:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendarwithisodefault step 2:
|
|
||||||
2. Return ? ToTemporalCalendar(_temporalCalendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = new Temporal.PlainYearMonth(2000, 5, temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = new Temporal.PlainYearMonth(2000, 5, arg, 1);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -2,21 +2,39 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.instant.prototype.tozoneddatetime
|
esid: sec-temporal.timezone.prototype.getplaindatetimefor
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.instant.prototype.tozoneddatetime step 6:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
6. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const instant = new Temporal.Instant(1_000_000_000_987_654_321n);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const timezone = new Temporal.TimeZone("UTC");
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
const result = timezone.getPlainDateTimeFor(instant, temporalObject);
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const instance = new Temporal.TimeZone("UTC");
|
||||||
|
const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,18 +5,35 @@
|
|||||||
esid: sec-temporal.zoneddatetime
|
esid: sec-temporal.zoneddatetime
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.zoneddatetime step 5:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendarwithisodefault step 2:
|
|
||||||
2. Return ? ToTemporalCalendar(_temporalCalendarLike_).
|
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const result = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject);
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = new Temporal.ZonedDateTime(0n, "UTC", arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
@ -5,17 +5,36 @@
|
|||||||
esid: sec-temporal.zoneddatetime.prototype.withcalendar
|
esid: sec-temporal.zoneddatetime.prototype.withcalendar
|
||||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||||
info: |
|
info: |
|
||||||
sec-temporal.zoneddatetime.prototype.withcalendar step 3:
|
sec-temporal-totemporalcalendar step 1.b:
|
||||||
3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
|
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||||
sec-temporal-totemporalcalendar step 1.a:
|
|
||||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
|
||||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
includes: [compareArray.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC");
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const result = zonedDateTime.withCalendar(temporalObject);
|
const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
|
||||||
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
|
|
||||||
|
[plainDate, plainDateTime, plainTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
|
||||||
|
const actual = [];
|
||||||
|
const expected = [];
|
||||||
|
|
||||||
|
const calendar = arg.getISOFields().calendar;
|
||||||
|
|
||||||
|
Object.defineProperty(arg, "calendar", {
|
||||||
|
get() {
|
||||||
|
actual.push("get calendar");
|
||||||
|
return calendar;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { id: "replace-me" });
|
||||||
|
const result = instance.withCalendar(arg);
|
||||||
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
|
||||||
|
|
||||||
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user