mirror of https://github.com/tc39/test262.git
Temporal: Don't pass custom calendar in helper tests
This is no longer necessary if there are no calendar objects.
This commit is contained in:
parent
9c6734f39b
commit
372527e572
|
@ -332,11 +332,9 @@ var TemporalHelpers = {
|
||||||
* Temporal.PlainDateTime instance, convert to the desired type by reading the
|
* Temporal.PlainDateTime instance, convert to the desired type by reading the
|
||||||
* PlainDateTime's internal slots, rather than calling any getters.
|
* PlainDateTime's internal slots, rather than calling any getters.
|
||||||
*
|
*
|
||||||
* func(datetime, calendar) is the actual operation to test, that must
|
* func(datetime) is the actual operation to test, that must
|
||||||
* internally call the abstract operation ToTemporalDate or ToTemporalTime.
|
* internally call the abstract operation ToTemporalDate or ToTemporalTime.
|
||||||
* It is passed a Temporal.PlainDateTime instance, as well as the instance's
|
* It is passed a Temporal.PlainDateTime instance.
|
||||||
* calendar object (so that it doesn't have to call the calendar getter itself
|
|
||||||
* if it wants to make any assertions about the calendar.)
|
|
||||||
*/
|
*/
|
||||||
checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") {
|
checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") {
|
||||||
const actual = [];
|
const actual = [];
|
||||||
|
@ -370,7 +368,7 @@ var TemporalHelpers = {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
func(datetime, calendar);
|
func(datetime);
|
||||||
assert.compareArray(actual, expected, `${message}: property getters not called`);
|
assert.compareArray(actual, expected, `${message}: property getters not called`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -888,42 +886,13 @@ var TemporalHelpers = {
|
||||||
* Check that any calendar-carrying Temporal object has its [[Calendar]]
|
* Check that any calendar-carrying Temporal object has its [[Calendar]]
|
||||||
* internal slot read by ToTemporalCalendar, and does not fetch the calendar
|
* internal slot read by ToTemporalCalendar, and does not fetch the calendar
|
||||||
* by calling getters.
|
* by calling getters.
|
||||||
* The custom calendar object is passed in to func() so that it can do its
|
|
||||||
* own additional assertions involving the calendar if necessary. (Sometimes
|
|
||||||
* there is nothing to assert as the calendar isn't stored anywhere that can
|
|
||||||
* be asserted about.)
|
|
||||||
*/
|
*/
|
||||||
checkToTemporalCalendarFastPath(func) {
|
checkToTemporalCalendarFastPath(func) {
|
||||||
class CalendarFastPathCheck extends Temporal.Calendar {
|
const plainDate = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||||
constructor() {
|
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601");
|
||||||
super("iso8601");
|
const plainMonthDay = new Temporal.PlainMonthDay(5, 2, "iso8601");
|
||||||
}
|
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, "iso8601");
|
||||||
|
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601");
|
||||||
dateFromFields(...args) {
|
|
||||||
return super.dateFromFields(...args).withCalendar(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
monthDayFromFields(...args) {
|
|
||||||
const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields();
|
|
||||||
return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear);
|
|
||||||
}
|
|
||||||
|
|
||||||
yearMonthFromFields(...args) {
|
|
||||||
const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields();
|
|
||||||
return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay);
|
|
||||||
}
|
|
||||||
|
|
||||||
toString() {
|
|
||||||
return "fast-path-check";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const calendar = new CalendarFastPathCheck();
|
|
||||||
|
|
||||||
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
|
|
||||||
const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar);
|
|
||||||
const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar);
|
|
||||||
const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar);
|
|
||||||
const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
|
||||||
|
|
||||||
[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => {
|
[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => {
|
||||||
const actual = [];
|
const actual = [];
|
||||||
|
@ -936,7 +905,7 @@ var TemporalHelpers = {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
func(temporalObject, calendar);
|
func(temporalObject);
|
||||||
assert.compareArray(actual, expected, "calendar getter not called");
|
assert.compareArray(actual, expected, "calendar getter not called");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -986,11 +955,11 @@ var TemporalHelpers = {
|
||||||
Object.defineProperty(date, "calendar", {
|
Object.defineProperty(date, "calendar", {
|
||||||
get() {
|
get() {
|
||||||
actual.push("get calendar");
|
actual.push("get calendar");
|
||||||
return calendar;
|
return "iso8601";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
func(date, calendar);
|
func(date);
|
||||||
assert.compareArray(actual, expected, "property getters not called");
|
assert.compareArray(actual, expected, "property getters not called");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,7 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => {
|
TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => {
|
||||||
const result = Temporal.PlainDate.from(datetime);
|
const result = Temporal.PlainDate.from(datetime);
|
||||||
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
|
TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2);
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,6 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const date = new Temporal.PlainDate(2000, 5, 2, temporalObject);
|
const date = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||||
date.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
date.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const date = new Temporal.PlainDate(2000, 5, 2, temporalObject);
|
const date = new Temporal.PlainDate(2000, 5, 2);
|
||||||
date.since({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
date.since({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const date = new Temporal.PlainDate(2000, 5, 2, temporalObject);
|
const date = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||||
date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => {
|
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
|
||||||
const result = Temporal.PlainDateTime.from(date);
|
const result = Temporal.PlainDateTime.from(date);
|
||||||
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed");
|
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed");
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "calendar result");
|
assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar result");
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject });
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject);
|
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
datetime.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
datetime.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject);
|
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
datetime.since({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
datetime.since({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => {
|
TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => {
|
||||||
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, calendar);
|
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, "iso8601");
|
||||||
const result = datetime.until(date);
|
const result = datetime.until(date);
|
||||||
assert.sameValue(result.total({ unit: "nanoseconds" }), -987654321, "PlainDate is converted to midnight");
|
assert.sameValue(result.total({ unit: "nanoseconds" }), -987654321, "PlainDate is converted to midnight");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject);
|
const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject });
|
const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject });
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const monthday = new Temporal.PlainMonthDay(5, 2, temporalObject);
|
const monthday = new Temporal.PlainMonthDay(5, 2);
|
||||||
monthday.equals({ monthCode: "M06", day: 2, calendar: temporalObject });
|
monthday.equals({ monthCode: "M06", day: 2, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject });
|
const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject });
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject);
|
const yearmonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
yearmonth.equals({ year: 2005, month: 6, calendar: temporalObject });
|
yearmonth.equals({ year: 2005, month: 6, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject);
|
const yearmonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
yearmonth.since({ year: 2005, month: 6, calendar: temporalObject });
|
yearmonth.since({ year: 2005, month: 6, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject);
|
const yearmonth = new Temporal.PlainYearMonth(2000, 5);
|
||||||
yearmonth.until({ year: 2005, month: 6, calendar: temporalObject });
|
yearmonth.until({ year: 2005, month: 6, calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject });
|
const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject });
|
||||||
assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
|
assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject);
|
const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject });
|
datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,6 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => {
|
||||||
const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject);
|
const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
|
||||||
datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject });
|
datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject });
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue