mirror of https://github.com/tc39/test262.git
Temporal: Remove calendar and time zone observers
These are no longer possible without custom objects. Also add an exception for calendar and timeZone properties in property bag observers so they are not treated as objects.
This commit is contained in:
parent
27bc974287
commit
5cd7e9077d
|
@ -1421,142 +1421,6 @@ var TemporalHelpers = {
|
|||
};
|
||||
},
|
||||
|
||||
/*
|
||||
* calendarObserver:
|
||||
* A custom calendar that behaves exactly like the ISO 8601 calendar but
|
||||
* tracks calls to any of its methods, and Get/Has operations on its
|
||||
* properties, by appending messages to an array. This is for the purpose of
|
||||
* testing order of operations that are observable from user code.
|
||||
* objectName is used in the log.
|
||||
*/
|
||||
calendarObserver(calls, objectName, methodOverrides = {}) {
|
||||
function removeExtraHasPropertyChecks(objectName, calls) {
|
||||
// Inserting the tracking calendar into the return values of methods
|
||||
// that we chain up into the ISO calendar for, causes extra HasProperty
|
||||
// checks, which we observe. This removes them so that we don't leak
|
||||
// implementation details of the helper into the test code.
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.year`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.monthCode`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.month`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.id`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.fields`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.day`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`);
|
||||
assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`);
|
||||
}
|
||||
|
||||
const iso8601 = new Temporal.Calendar("iso8601");
|
||||
const trackingMethods = {
|
||||
dateFromFields(...args) {
|
||||
calls.push(`call ${objectName}.dateFromFields`);
|
||||
if ('dateFromFields' in methodOverrides) {
|
||||
const value = methodOverrides.dateFromFields;
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
}
|
||||
const originalResult = iso8601.dateFromFields(...args);
|
||||
// Replace the calendar in the result with the call-tracking calendar
|
||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||
const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
||||
removeExtraHasPropertyChecks(objectName, calls);
|
||||
return result;
|
||||
},
|
||||
yearMonthFromFields(...args) {
|
||||
calls.push(`call ${objectName}.yearMonthFromFields`);
|
||||
if ('yearMonthFromFields' in methodOverrides) {
|
||||
const value = methodOverrides.yearMonthFromFields;
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
}
|
||||
const originalResult = iso8601.yearMonthFromFields(...args);
|
||||
// Replace the calendar in the result with the call-tracking calendar
|
||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||
const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay);
|
||||
removeExtraHasPropertyChecks(objectName, calls);
|
||||
return result;
|
||||
},
|
||||
monthDayFromFields(...args) {
|
||||
calls.push(`call ${objectName}.monthDayFromFields`);
|
||||
if ('monthDayFromFields' in methodOverrides) {
|
||||
const value = methodOverrides.monthDayFromFields;
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
}
|
||||
const originalResult = iso8601.monthDayFromFields(...args);
|
||||
// Replace the calendar in the result with the call-tracking calendar
|
||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||
const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear);
|
||||
removeExtraHasPropertyChecks(objectName, calls);
|
||||
return result;
|
||||
},
|
||||
dateAdd(...args) {
|
||||
calls.push(`call ${objectName}.dateAdd`);
|
||||
if ('dateAdd' in methodOverrides) {
|
||||
const value = methodOverrides.dateAdd;
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
}
|
||||
const originalResult = iso8601.dateAdd(...args);
|
||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||
const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
||||
removeExtraHasPropertyChecks(objectName, calls);
|
||||
return result;
|
||||
},
|
||||
id: "iso8601",
|
||||
};
|
||||
// Automatically generate the other methods that don't need any custom code
|
||||
[
|
||||
"dateUntil",
|
||||
"day",
|
||||
"dayOfWeek",
|
||||
"dayOfYear",
|
||||
"daysInMonth",
|
||||
"daysInWeek",
|
||||
"daysInYear",
|
||||
"era",
|
||||
"eraYear",
|
||||
"fields",
|
||||
"inLeapYear",
|
||||
"mergeFields",
|
||||
"month",
|
||||
"monthCode",
|
||||
"monthsInYear",
|
||||
"toString",
|
||||
"weekOfYear",
|
||||
"year",
|
||||
"yearOfWeek",
|
||||
].forEach((methodName) => {
|
||||
trackingMethods[methodName] = function (...args) {
|
||||
calls.push(`call ${formatPropertyName(methodName, objectName)}`);
|
||||
if (methodName in methodOverrides) {
|
||||
const value = methodOverrides[methodName];
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
}
|
||||
return iso8601[methodName](...args);
|
||||
};
|
||||
});
|
||||
return new Proxy(trackingMethods, {
|
||||
get(target, key, receiver) {
|
||||
const result = Reflect.get(target, key, receiver);
|
||||
calls.push(`get ${formatPropertyName(key, objectName)}`);
|
||||
return result;
|
||||
},
|
||||
has(target, key) {
|
||||
calls.push(`has ${formatPropertyName(key, objectName)}`);
|
||||
return Reflect.has(target, key);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* oneShiftTimeZone(shiftInstant, shiftNanoseconds):
|
||||
*
|
||||
|
@ -1633,8 +1497,11 @@ var TemporalHelpers = {
|
|||
* and valueOf methods in the same array. This is for the purpose of testing
|
||||
* order of operations that are observable from user code. objectName is used
|
||||
* in the log.
|
||||
* If skipToPrimitive is given, it must be an array of property keys. Those
|
||||
* properties will not have a TemporalHelpers.toPrimitiveObserver returned,
|
||||
* and instead just be returned directly.
|
||||
*/
|
||||
propertyBagObserver(calls, propertyBag, objectName) {
|
||||
propertyBagObserver(calls, propertyBag, objectName, skipToPrimitive) {
|
||||
return new Proxy(propertyBag, {
|
||||
ownKeys(target) {
|
||||
calls.push(`ownKeys ${objectName}`);
|
||||
|
@ -1653,47 +1520,10 @@ var TemporalHelpers = {
|
|||
if ((result !== null && typeof result === "object") || typeof result === "function") {
|
||||
return result;
|
||||
}
|
||||
return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`);
|
||||
},
|
||||
has(target, key) {
|
||||
calls.push(`has ${formatPropertyName(key, objectName)}`);
|
||||
return Reflect.has(target, key);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
* timeZoneObserver:
|
||||
* A custom calendar that behaves exactly like the UTC time zone but tracks
|
||||
* calls to any of its methods, and Get/Has operations on its properties, by
|
||||
* appending messages to an array. This is for the purpose of testing order of
|
||||
* operations that are observable from user code. objectName is used in the
|
||||
* log. methodOverrides is an optional object containing properties with the
|
||||
* same name as Temporal.TimeZone methods. If the property value is a function
|
||||
* it will be called with the proper arguments instead of the UTC method.
|
||||
* Otherwise, the property value will be returned directly.
|
||||
*/
|
||||
timeZoneObserver(calls, objectName, methodOverrides = {}) {
|
||||
const utc = new Temporal.TimeZone("UTC");
|
||||
const trackingMethods = {
|
||||
id: "UTC",
|
||||
};
|
||||
// Automatically generate the methods
|
||||
["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => {
|
||||
trackingMethods[methodName] = function (...args) {
|
||||
calls.push(`call ${formatPropertyName(methodName, objectName)}`);
|
||||
if (methodName in methodOverrides) {
|
||||
const value = methodOverrides[methodName];
|
||||
return typeof value === "function" ? value(...args) : value;
|
||||
if (skipToPrimitive && skipToPrimitive.indexOf(key) >= 0) {
|
||||
return result;
|
||||
}
|
||||
return utc[methodName](...args);
|
||||
};
|
||||
});
|
||||
return new Proxy(trackingMethods, {
|
||||
get(target, key, receiver) {
|
||||
const result = Reflect.get(target, key, receiver);
|
||||
calls.push(`get ${formatPropertyName(key, objectName)}`);
|
||||
return result;
|
||||
return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`);
|
||||
},
|
||||
has(target, key) {
|
||||
calls.push(`has ${formatPropertyName(key, objectName)}`);
|
||||
|
|
|
@ -146,8 +146,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
month: 5,
|
||||
monthCode: "M05",
|
||||
day: 2,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
}, "options.relativeTo", ["calendar"]);
|
||||
|
||||
function createOptionsObserver(relativeTo = undefined) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, { relativeTo }, "options");
|
||||
|
@ -249,9 +249,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "options.relativeTo", ["calendar", "timeZone"]);
|
||||
|
||||
// order of observable operations with zoned relativeTo and without calendar units except days
|
||||
Temporal.Duration.compare(
|
||||
|
|
|
@ -112,8 +112,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
month: 5,
|
||||
monthCode: "M05",
|
||||
day: 2,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
}, "options.relativeTo", ["calendar"]);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.round(createOptionsObserver({ relativeTo: plainRelativeTo }));
|
||||
|
@ -315,9 +315,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "options.relativeTo", ["calendar", "timeZone"]);
|
||||
|
||||
// basic order of operations with ZonedDateTime relativeTo:
|
||||
instance.round(createOptionsObserver({ relativeTo: zonedRelativeTo }));
|
||||
|
|
|
@ -95,8 +95,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
month: 5,
|
||||
monthCode: "M05",
|
||||
day: 2,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
}, "options.relativeTo", ["calendar"]);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: plainRelativeTo }));
|
||||
|
@ -254,9 +254,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"),
|
||||
}, "options.relativeTo");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "options.relativeTo", ["calendar", "timeZone"]);
|
||||
|
||||
// basic order of observable operations, without rounding:
|
||||
instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: zonedRelativeTo }));
|
||||
|
|
|
@ -34,8 +34,8 @@ instance.toString(
|
|||
fractionalSecondDigits: "auto",
|
||||
roundingMode: "halfExpand",
|
||||
smallestUnit: "millisecond",
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "options.timeZone"),
|
||||
}, "options"),
|
||||
timeZone: "UTC",
|
||||
}, "options", ["timeZone"]),
|
||||
);
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
actual.splice(0); // clear
|
||||
|
|
|
@ -58,14 +58,13 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "fields.calendar");
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 1.7,
|
||||
month: 1.7,
|
||||
monthCode: "M01",
|
||||
day: 1.7,
|
||||
calendar,
|
||||
}, "fields");
|
||||
calendar: "iso8601",
|
||||
}, "fields", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
overflow: "constrain",
|
||||
|
|
|
@ -50,8 +50,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
|
||||
|
|
|
@ -75,16 +75,15 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar);
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||
|
||||
const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
month: 6,
|
||||
monthCode: "M06",
|
||||
day: 2,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -50,10 +50,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -75,16 +75,15 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar);
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||
|
||||
const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
month: 6,
|
||||
monthCode: "M06",
|
||||
day: 2,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -56,8 +56,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
|
|||
millisecond: 1.7,
|
||||
microsecond: 1.7,
|
||||
nanosecond: 1.7,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"),
|
||||
}, "fields");
|
||||
calendar: "iso8601",
|
||||
}, "fields", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
overflow: "constrain",
|
||||
|
|
|
@ -50,8 +50,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar);
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601");
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
|
||||
|
|
|
@ -93,8 +93,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar);
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601");
|
||||
|
||||
const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
|
@ -107,8 +106,8 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
|||
millisecond: 250,
|
||||
microsecond: 500,
|
||||
nanosecond: 750,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -50,10 +50,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601");
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -25,8 +25,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, calendar);
|
||||
const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, "iso8601");
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
|
||||
|
|
|
@ -93,8 +93,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar);
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601");
|
||||
|
||||
const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
|
@ -107,8 +106,8 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
|||
millisecond: 250,
|
||||
microsecond: 500,
|
||||
nanosecond: 750,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -73,7 +73,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const calendar = "iso8601";
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
|
|
|
@ -68,8 +68,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
|
|||
month: 1.7,
|
||||
monthCode: "M01",
|
||||
day: 1.7,
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"),
|
||||
}, "fields");
|
||||
calendar: "iso8601",
|
||||
}, "fields", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
overflow: "constrain",
|
||||
|
|
|
@ -16,10 +16,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainMonthDay(5, 2, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainMonthDay(5, 2, "iso8601");
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
calendarName: "auto",
|
||||
|
|
|
@ -52,10 +52,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainMonthDay(5, 2, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainMonthDay(5, 2, "iso8601");
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 1.7,
|
||||
|
|
|
@ -62,7 +62,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 1.7,
|
||||
nanosecond: 1.7,
|
||||
calendar: "iso8601",
|
||||
}, "other");
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
roundingIncrement: 1,
|
||||
|
|
|
@ -62,7 +62,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 1.7,
|
||||
nanosecond: 1.7,
|
||||
calendar: "iso8601",
|
||||
}, "other");
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
roundingIncrement: 1,
|
||||
|
|
|
@ -65,8 +65,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
|
|||
year: 1.7,
|
||||
month: 1.7,
|
||||
monthCode: "M01",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"),
|
||||
}, "fields");
|
||||
calendar: "iso8601",
|
||||
}, "fields", ["calendar"]);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
overflow: "constrain",
|
||||
|
|
|
@ -78,10 +78,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -96,15 +96,14 @@ const expected = expectedMinimal.concat([
|
|||
]);
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1);
|
||||
|
||||
const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
month: 6,
|
||||
monthCode: "M06",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -81,10 +81,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601");
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -16,10 +16,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||
|
||||
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||
calendarName: "auto",
|
||||
|
|
|
@ -96,15 +96,14 @@ const expected = expectedMinimal.concat([
|
|||
]);
|
||||
const actual = [];
|
||||
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1);
|
||||
|
||||
const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2001,
|
||||
month: 6,
|
||||
monthCode: "M06",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
}, "other");
|
||||
calendar: "iso8601"
|
||||
}, "other", ["calendar"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -51,10 +51,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 1.7,
|
||||
|
|
|
@ -165,9 +165,9 @@ const one = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "one.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "one.timeZone"),
|
||||
}, "one");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "one", ["calendar", "timeZone"]);
|
||||
|
||||
const two = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 2014,
|
||||
|
@ -181,9 +181,9 @@ const two = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 456,
|
||||
nanosecond: 789,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "two.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "two.timeZone"),
|
||||
}, "two");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "two", ["calendar", "timeZone"]);
|
||||
|
||||
Temporal.ZonedDateTime.compare(one, two);
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
|
|
|
@ -112,9 +112,9 @@ const from = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "item.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "item.timeZone"),
|
||||
}, "item");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "item", ["calendar", "timeZone"]);
|
||||
|
||||
function createOptionsObserver({ overflow = "constrain", disambiguation = "compatible", offset = "reject" } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -56,11 +56,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const duration = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -101,18 +101,11 @@ const other = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 654,
|
||||
nanosecond: 321,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "other", ["calendar", "timeZone"]);
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(
|
||||
988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */
|
||||
TemporalHelpers.timeZoneObserver(actual, "this.timeZone"),
|
||||
TemporalHelpers.calendarObserver(actual, "this.calendar"),
|
||||
);
|
||||
// clear any observable operations that happen due to time zone or calendar
|
||||
// calls on the constructor
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.ZonedDateTime(988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ "UTC");
|
||||
|
||||
instance.equals(other);
|
||||
assert.compareArray(actual, expected, "order of operations");
|
||||
|
|
|
@ -104,8 +104,6 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const ownTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
|
||||
const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, ownTimeZone, ownCalendar);
|
||||
|
||||
const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone();
|
||||
|
@ -132,9 +130,9 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 500,
|
||||
nanosecond: 750,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "other", ["calendar", "timeZone"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -56,11 +56,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC", "iso8601");
|
||||
|
||||
const duration = TemporalHelpers.propertyBagObserver(actual, {
|
||||
years: 1,
|
||||
|
|
|
@ -34,11 +34,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
instance.toString(
|
||||
TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -132,9 +132,9 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, {
|
|||
microsecond: 500,
|
||||
nanosecond: 750,
|
||||
offset: "+00:00",
|
||||
calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"),
|
||||
timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"),
|
||||
}, "other");
|
||||
calendar: "iso8601",
|
||||
timeZone: "UTC",
|
||||
}, "other", ["calendar", "timeZone"]);
|
||||
|
||||
function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) {
|
||||
return TemporalHelpers.propertyBagObserver(actual, {
|
||||
|
|
|
@ -92,11 +92,7 @@ const expected = [
|
|||
];
|
||||
const actual = [];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone");
|
||||
const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar);
|
||||
// clear observable operations that occurred during the constructor call
|
||||
actual.splice(0);
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||
year: 1.7,
|
||||
|
|
Loading…
Reference in New Issue