mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +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
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.calendar.from step 1:
|
||||
1. Return ? ToTemporalCalendar(_item_).
|
||||
sec-temporal-totemporalcalendar step 1.a:
|
||||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const newCalendar = Temporal.Calendar.from(temporalObject);
|
||||
assert.sameValue(newCalendar, calendar, "calendar object retrieved from internal slot");
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.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
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.instant.prototype.tozoneddatetime step 6:
|
||||
6. 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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const instant = new Temporal.Instant(1_000_000_000_987_654_321n);
|
||||
const result = instant.toZonedDateTime({ timeZone: "UTC", calendar: temporalObject });
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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 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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.now.plaindate
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.now.plaindate step 1:
|
||||
1. Let _dateTime_ be ? SystemDateTime(_temporalTimeZoneLike_, _calendar_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = Temporal.Now.plainDate(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.now.plaindatetime
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.now.plaindatetime step 1:
|
||||
1. Return ? SystemDateTime(_temporalTimeZoneLike_, _calendar_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
features: [Temporal, arrow-function]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = Temporal.Now.plainDateTime(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.now.zoneddatetime step 1:
|
||||
1. Return ? SystemZonedDateTime(_temporalTimeZoneLike_, _calendar_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = Temporal.Now.zonedDateTime(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.plaindate
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plaindate step 5:
|
||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = new Temporal.PlainDate(2000, 5, 2, temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,17 +5,36 @@
|
||||
esid: sec-temporal.plaindate.prototype.withcalendar
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plaindate.prototype.withcalendar 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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
const result = plainDate.withCalendar(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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 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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.plaindatetime
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plaindatetime step 11:
|
||||
11. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject);
|
||||
assert.sameValue(result.calendar, calendar, 'Temporal object coerced to calendar');
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.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
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plaindatetime.prototype.withcalendar 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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
const result = plainDateTime.withCalendar(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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 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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.plainmonthday
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plainmonthday step 5:
|
||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = new Temporal.PlainMonthDay(5, 2, temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.plainyearmonth
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.plainyearmonth step 5:
|
||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = new Temporal.PlainYearMonth(2000, 5, temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -2,21 +2,39 @@
|
||||
// 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
|
||||
info: |
|
||||
sec-temporal.instant.prototype.tozoneddatetime step 6:
|
||||
6. 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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const instant = new Temporal.Instant(1_000_000_000_987_654_321n);
|
||||
const timezone = new Temporal.TimeZone("UTC");
|
||||
const result = timezone.getPlainDateTimeFor(instant, temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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 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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,18 +5,35 @@
|
||||
esid: sec-temporal.zoneddatetime
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.zoneddatetime step 5:
|
||||
5. Let _calendar_ be ? ToTemporalCalendarWithISODefault(_calendarLike_).
|
||||
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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const result = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
@ -5,17 +5,36 @@
|
||||
esid: sec-temporal.zoneddatetime.prototype.withcalendar
|
||||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
|
||||
info: |
|
||||
sec-temporal.zoneddatetime.prototype.withcalendar 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
|
||||
sec-temporal-totemporalcalendar step 1.b:
|
||||
b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
|
||||
i. Return _temporalCalendarLike_.[[Calendar]].
|
||||
includes: [compareArray.js, temporalHelpers.js]
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
||||
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC");
|
||||
const result = zonedDateTime.withCalendar(temporalObject);
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2);
|
||||
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 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.compareArray(actual, expected, "calendar getter not called");
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user