mirror of https://github.com/tc39/test262.git
Temporal: Add TemporalHelpers.propertyBagObserver()
Many existing tests use a Proxy to test the order of observable operations on a property bag argument that gets passed in to a Temporal API. I am going to write several more tests that do this, as well. This seems like a good thing to put into TemporalHelpers, where it can be implemented consistently so that we don't get discrepancies in which operations are tracked. (For example, we had some tests which didn't test for an ownKeys operation that was supposed to be there.) Updates existing tests to use this helper.
This commit is contained in:
parent
38dd3c2823
commit
ef59ea225a
|
@ -1444,6 +1444,41 @@ var TemporalHelpers = {
|
||||||
return new OneShiftTimeZone(shiftInstant, shiftNanoseconds);
|
return new OneShiftTimeZone(shiftInstant, shiftNanoseconds);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* propertyBagObserver():
|
||||||
|
* Returns an object that behaves like the given propertyBag but tracks Get
|
||||||
|
* and Has operations on any of its properties, by appending messages to an
|
||||||
|
* array. If the value of a property in propertyBag is a primitive, the value
|
||||||
|
* of the returned object's property will additionally be a
|
||||||
|
* TemporalHelpers.toPrimitiveObserver that will track calls to its toString
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
propertyBagObserver(calls, propertyBag, objectName) {
|
||||||
|
return new Proxy(propertyBag, {
|
||||||
|
ownKeys(target) {
|
||||||
|
calls.push(`ownKeys ${objectName}`);
|
||||||
|
return Reflect.ownKeys(target);
|
||||||
|
},
|
||||||
|
get(target, key, receiver) {
|
||||||
|
calls.push(`get ${formatPropertyName(key, objectName)}`);
|
||||||
|
const result = Reflect.get(target, key, receiver);
|
||||||
|
if (result === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (typeof result === "object") {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`);
|
||||||
|
},
|
||||||
|
has(target, key) {
|
||||||
|
calls.push(`has ${formatPropertyName(key, objectName)}`);
|
||||||
|
return Reflect.has(target, key);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* specificOffsetTimeZone():
|
* specificOffsetTimeZone():
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,24 +16,17 @@ const expected = [
|
||||||
"call inner.toString",
|
"call inner.toString",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const calendar = new Proxy({}, {
|
const calendar = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
has(t, p) {
|
calendar: new Proxy(TemporalHelpers.toPrimitiveObserver(actual, "iso8601", "inner"), {
|
||||||
actual.push(`has outer.${p}`);
|
has(t, p) {
|
||||||
return true;
|
actual.push(`has inner.${p}`);
|
||||||
},
|
return true;
|
||||||
get(t, p) {
|
},
|
||||||
actual.push(`get outer.${p}`);
|
get(t, p) {
|
||||||
return new Proxy(TemporalHelpers.toPrimitiveObserver(actual, "iso8601", "inner"), {
|
return t[p];
|
||||||
has(t, p) {
|
},
|
||||||
actual.push(`has inner.${p}`);
|
}),
|
||||||
return true;
|
}, "outer");
|
||||||
},
|
|
||||||
get(t, p) {
|
|
||||||
return t[p];
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.Calendar.from(calendar);
|
const result = Temporal.Calendar.from(calendar);
|
||||||
assert.sameValue(result.id, "iso8601");
|
assert.sameValue(result.id, "iso8601");
|
||||||
assert.compareArray(actual, expected);
|
assert.compareArray(actual, expected);
|
||||||
|
|
|
@ -29,40 +29,18 @@ const actual = [];
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
const instance = new Temporal.Calendar("iso8601");
|
||||||
|
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const arg1 = new Proxy(fields, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get fields.${key}`);
|
|
||||||
if (key === "calendar") return instance;
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has fields.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const options = {
|
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
overflow: "reject",
|
overflow: "reject",
|
||||||
};
|
}, "options");
|
||||||
const arg2 = new Proxy(options, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get options.${key}`);
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has options.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = instance.dateFromFields(arg1, arg2);
|
const result = instance.dateFromFields(fields, options);
|
||||||
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1, "date result");
|
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1, "date result");
|
||||||
assert.sameValue(result.calendar, instance, "calendar result");
|
assert.sameValue(result.calendar, instance, "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -29,40 +29,18 @@ const actual = [];
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
const instance = new Temporal.Calendar("iso8601");
|
||||||
|
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const arg1 = new Proxy(fields, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get fields.${key}`);
|
|
||||||
if (key === "calendar") return instance;
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has fields.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const options = {
|
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
overflow: "reject",
|
overflow: "reject",
|
||||||
};
|
}, "options");
|
||||||
const arg2 = new Proxy(options, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get options.${key}`);
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has options.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = instance.monthDayFromFields(arg1, arg2);
|
const result = instance.monthDayFromFields(fields, options);
|
||||||
TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDay result");
|
TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDay result");
|
||||||
assert.sameValue(result.calendar, instance, "calendar result");
|
assert.sameValue(result.calendar, instance, "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -26,39 +26,17 @@ const actual = [];
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
const instance = new Temporal.Calendar("iso8601");
|
||||||
|
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
};
|
}, "fields");
|
||||||
const arg1 = new Proxy(fields, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get fields.${key}`);
|
|
||||||
if (key === "calendar") return instance;
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has fields.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const options = {
|
const options = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
overflow: "reject",
|
overflow: "reject",
|
||||||
};
|
}, "options");
|
||||||
const arg2 = new Proxy(options, {
|
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get options.${key}`);
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has options.${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = instance.yearMonthFromFields(arg1, arg2);
|
const result = instance.yearMonthFromFields(fields, options);
|
||||||
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01", "yearMonth result");
|
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01", "yearMonth result");
|
||||||
assert.sameValue(result.calendar, instance, "calendar result");
|
assert.sameValue(result.calendar, instance, "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -9,39 +9,39 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -52,18 +52,7 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.Duration.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.Duration.from(argument);
|
|
||||||
TemporalHelpers.assertDuration(result, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertDuration(result, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -11,39 +11,39 @@ features: [Temporal]
|
||||||
const instance = new Temporal.Duration(1, 2, 0, 4, 5, 6, 7, 987, 654, 321);
|
const instance = new Temporal.Duration(1, 2, 0, 4, 5, 6, 7, 987, 654, 321);
|
||||||
const relativeTo = new Temporal.PlainDateTime(2000, 1, 1);
|
const relativeTo = new Temporal.PlainDateTime(2000, 1, 1);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -54,21 +54,7 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields, { relativeTo });
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument, { relativeTo });
|
|
||||||
TemporalHelpers.assertDuration(result, 2, 3, 0, 12, 6, 7, 8, 988, 655, 322);
|
TemporalHelpers.assertDuration(result, 2, 3, 0, 12, 6, 7, 8, 988, 655, 322);
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -11,39 +11,39 @@ features: [Temporal]
|
||||||
const instance = new Temporal.Duration(1, 2, 1, 4, 5, 6, 7, 987, 654, 321);
|
const instance = new Temporal.Duration(1, 2, 1, 4, 5, 6, 7, 987, 654, 321);
|
||||||
const relativeTo = new Temporal.PlainDateTime(2000, 1, 1);
|
const relativeTo = new Temporal.PlainDateTime(2000, 1, 1);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -54,21 +54,7 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields, { relativeTo });
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument, { relativeTo });
|
|
||||||
TemporalHelpers.assertDuration(result, 0, 1, 0, 3, 4, 5, 6, 986, 653, 320);
|
TemporalHelpers.assertDuration(result, 0, 1, 0, 3, 4, 5, 6, 986, 653, 320);
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321);
|
const instance = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,21 +53,7 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.with(argument);
|
|
||||||
TemporalHelpers.assertDuration(result, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertDuration(result, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,52 +10,38 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.Instant(10n);
|
const instance = new Temporal.Instant(10n);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get years",
|
"get fields.years",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
hours: 1,
|
hours: 1,
|
||||||
minutes: 1,
|
minutes: 1,
|
||||||
seconds: 1,
|
seconds: 1,
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument);
|
|
||||||
assert.sameValue(result.epochNanoseconds, 3661001001011n, "epochNanoseconds result");
|
assert.sameValue(result.epochNanoseconds, 3661001001011n, "epochNanoseconds result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,52 +10,38 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.Instant(10n);
|
const instance = new Temporal.Instant(10n);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get years",
|
"get fields.years",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
hours: 1,
|
hours: 1,
|
||||||
minutes: 1,
|
minutes: 1,
|
||||||
seconds: 1,
|
seconds: 1,
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument);
|
|
||||||
assert.sameValue(result.epochNanoseconds, -3661001000991n, "epochNanoseconds result");
|
assert.sameValue(result.epochNanoseconds, -3661001000991n, "epochNanoseconds result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -24,16 +24,7 @@ class CustomCalendar extends Temporal.Calendar {
|
||||||
|
|
||||||
const calendar = new CustomCalendar();
|
const calendar = new CustomCalendar();
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const item = new Proxy({ calendar }, {
|
const item = TemporalHelpers.propertyBagObserver(actual, { calendar }, "item");
|
||||||
has(target, property) {
|
|
||||||
actual.push(`has item.${property}`);
|
|
||||||
return property in target;
|
|
||||||
},
|
|
||||||
get(target, property) {
|
|
||||||
actual.push(`get item.${property}`);
|
|
||||||
return target[property];
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const plainDate = Temporal.PlainDate.from(item);
|
const plainDate = Temporal.PlainDate.from(item);
|
||||||
TemporalHelpers.assertPlainDate(plainDate, 2020, 7, "M07", 4);
|
TemporalHelpers.assertPlainDate(plainDate, 2020, 7, "M07", 4);
|
||||||
|
|
|
@ -9,40 +9,28 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.PlainDate.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.PlainDate.from(argument);
|
|
||||||
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
|
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument);
|
|
||||||
TemporalHelpers.assertPlainDate(result, 2001, 6, "M06", 10);
|
TemporalHelpers.assertPlainDate(result, 2001, 6, "M06", 10);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument);
|
|
||||||
TemporalHelpers.assertPlainDate(result, 1999, 3, "M03", 25);
|
TemporalHelpers.assertPlainDate(result, 1999, 3, "M03", 25);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,43 +10,29 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get timeZone",
|
"get fields.timeZone",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.with(argument);
|
|
||||||
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
|
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -9,40 +9,40 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get hour",
|
"get fields.hour",
|
||||||
"get hour.valueOf",
|
"get fields.hour.valueOf",
|
||||||
"call hour.valueOf",
|
"call fields.hour.valueOf",
|
||||||
"get microsecond",
|
"get fields.microsecond",
|
||||||
"get microsecond.valueOf",
|
"get fields.microsecond.valueOf",
|
||||||
"call microsecond.valueOf",
|
"call fields.microsecond.valueOf",
|
||||||
"get millisecond",
|
"get fields.millisecond",
|
||||||
"get millisecond.valueOf",
|
"get fields.millisecond.valueOf",
|
||||||
"call millisecond.valueOf",
|
"call fields.millisecond.valueOf",
|
||||||
"get minute",
|
"get fields.minute",
|
||||||
"get minute.valueOf",
|
"get fields.minute.valueOf",
|
||||||
"call minute.valueOf",
|
"call fields.minute.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get nanosecond",
|
"get fields.nanosecond",
|
||||||
"get nanosecond.valueOf",
|
"get fields.nanosecond.valueOf",
|
||||||
"call nanosecond.valueOf",
|
"call fields.nanosecond.valueOf",
|
||||||
"get second",
|
"get fields.second",
|
||||||
"get second.valueOf",
|
"get fields.second.valueOf",
|
||||||
"call second.valueOf",
|
"call fields.second.valueOf",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
|
@ -53,20 +53,8 @@ const fields = {
|
||||||
millisecond: 1.7,
|
millisecond: 1.7,
|
||||||
microsecond: 1.7,
|
microsecond: 1.7,
|
||||||
nanosecond: 1.7,
|
nanosecond: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.PlainDateTime.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.PlainDateTime.from(argument);
|
|
||||||
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument);
|
|
||||||
TemporalHelpers.assertPlainDateTime(result, 2001, 6, "M06", 10, 13, 35, 57, 988, 655, 322);
|
TemporalHelpers.assertPlainDateTime(result, 2001, 6, "M06", 10, 13, 35, 57, 988, 655, 322);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument);
|
|
||||||
TemporalHelpers.assertPlainDateTime(result, 1999, 3, "M03", 25, 11, 33, 55, 986, 653, 320);
|
TemporalHelpers.assertPlainDateTime(result, 1999, 3, "M03", 25, 11, 33, 55, 986, 653, 320);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -12,8 +12,8 @@ const actual = [];
|
||||||
const expected = [
|
const expected = [
|
||||||
"has timeZone.timeZone",
|
"has timeZone.timeZone",
|
||||||
"get options.disambiguation",
|
"get options.disambiguation",
|
||||||
"get disambiguation.toString",
|
"get options.disambiguation.toString",
|
||||||
"call disambiguation.toString",
|
"call options.disambiguation.toString",
|
||||||
"get timeZone.getPossibleInstantsFor",
|
"get timeZone.getPossibleInstantsFor",
|
||||||
"call timeZone.getPossibleInstantsFor",
|
"call timeZone.getPossibleInstantsFor",
|
||||||
];
|
];
|
||||||
|
@ -28,18 +28,7 @@ Object.defineProperty(Temporal.TimeZone, "from", {
|
||||||
const dateTime = Temporal.PlainDateTime.from("1975-02-02T14:25:36.123456789");
|
const dateTime = Temporal.PlainDateTime.from("1975-02-02T14:25:36.123456789");
|
||||||
const instant = Temporal.Instant.fromEpochNanoseconds(-205156799012345679n);
|
const instant = Temporal.Instant.fromEpochNanoseconds(-205156799012345679n);
|
||||||
|
|
||||||
const options = new Proxy({
|
const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options");
|
||||||
disambiguation: TemporalHelpers.toPrimitiveObserver(actual, "reject", "disambiguation"),
|
|
||||||
}, {
|
|
||||||
has(target, property) {
|
|
||||||
actual.push(`has options.${property}`);
|
|
||||||
return property in target;
|
|
||||||
},
|
|
||||||
get(target, property) {
|
|
||||||
actual.push(`get options.${property}`);
|
|
||||||
return target[property];
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const timeZone = new Proxy({
|
const timeZone = new Proxy({
|
||||||
getPossibleInstantsFor(dateTimeArg) {
|
getPossibleInstantsFor(dateTimeArg) {
|
||||||
|
|
|
@ -10,47 +10,41 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get timeZone",
|
"get fields.timeZone",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get hour",
|
"get fields.hour",
|
||||||
"get hour.valueOf",
|
"get fields.hour.valueOf",
|
||||||
"call hour.valueOf",
|
"call fields.hour.valueOf",
|
||||||
"get microsecond",
|
"get fields.microsecond",
|
||||||
"get microsecond.valueOf",
|
"get fields.microsecond.valueOf",
|
||||||
"call microsecond.valueOf",
|
"call fields.microsecond.valueOf",
|
||||||
"get millisecond",
|
"get fields.millisecond",
|
||||||
"get millisecond.valueOf",
|
"get fields.millisecond.valueOf",
|
||||||
"call millisecond.valueOf",
|
"call fields.millisecond.valueOf",
|
||||||
"get minute",
|
"get fields.minute",
|
||||||
"get minute.valueOf",
|
"get fields.minute.valueOf",
|
||||||
"call minute.valueOf",
|
"call fields.minute.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get nanosecond",
|
"get fields.nanosecond",
|
||||||
"get nanosecond.valueOf",
|
"get fields.nanosecond.valueOf",
|
||||||
"call nanosecond.valueOf",
|
"call fields.nanosecond.valueOf",
|
||||||
"get second",
|
"get fields.second",
|
||||||
"get second.valueOf",
|
"get fields.second.valueOf",
|
||||||
"call second.valueOf",
|
"call fields.second.valueOf",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
"get options.overflow",
|
|
||||||
"get options.overflow.toString",
|
|
||||||
"call options.overflow.toString",
|
|
||||||
"get options.overflow",
|
|
||||||
"get options.overflow.toString",
|
|
||||||
"call options.overflow.toString",
|
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
|
@ -61,28 +55,8 @@ const fields = {
|
||||||
millisecond: 1.7,
|
millisecond: 1.7,
|
||||||
microsecond: 1.7,
|
microsecond: 1.7,
|
||||||
nanosecond: 1.7,
|
nanosecond: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const options = {
|
|
||||||
get overflow() {
|
|
||||||
actual.push("get options.overflow");
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, "constrain", "options.overflow");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const result = instance.with(argument, options);
|
|
||||||
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -9,40 +9,28 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.PlainMonthDay.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.PlainMonthDay.from(argument);
|
|
||||||
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
|
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,42 +10,28 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainMonthDay(5, 2);
|
const instance = new Temporal.PlainMonthDay(5, 2);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get timeZone",
|
"get fields.timeZone",
|
||||||
"get day",
|
"get fields.day",
|
||||||
"get day.valueOf",
|
"get fields.day.valueOf",
|
||||||
"call day.valueOf",
|
"call fields.day.valueOf",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
day: 1.7,
|
day: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.with(argument);
|
|
||||||
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
|
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -9,48 +9,36 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get hour",
|
"get fields.hour",
|
||||||
"get hour.valueOf",
|
"get fields.hour.valueOf",
|
||||||
"call hour.valueOf",
|
"call fields.hour.valueOf",
|
||||||
"get microsecond",
|
"get fields.microsecond",
|
||||||
"get microsecond.valueOf",
|
"get fields.microsecond.valueOf",
|
||||||
"call microsecond.valueOf",
|
"call fields.microsecond.valueOf",
|
||||||
"get millisecond",
|
"get fields.millisecond",
|
||||||
"get millisecond.valueOf",
|
"get fields.millisecond.valueOf",
|
||||||
"call millisecond.valueOf",
|
"call fields.millisecond.valueOf",
|
||||||
"get minute",
|
"get fields.minute",
|
||||||
"get minute.valueOf",
|
"get fields.minute.valueOf",
|
||||||
"call minute.valueOf",
|
"call fields.minute.valueOf",
|
||||||
"get nanosecond",
|
"get fields.nanosecond",
|
||||||
"get nanosecond.valueOf",
|
"get fields.nanosecond.valueOf",
|
||||||
"call nanosecond.valueOf",
|
"call fields.nanosecond.valueOf",
|
||||||
"get second",
|
"get fields.second",
|
||||||
"get second.valueOf",
|
"get fields.second.valueOf",
|
||||||
"call second.valueOf",
|
"call fields.second.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
hour: 1.7,
|
hour: 1.7,
|
||||||
minute: 1.7,
|
minute: 1.7,
|
||||||
second: 1.7,
|
second: 1.7,
|
||||||
millisecond: 1.7,
|
millisecond: 1.7,
|
||||||
microsecond: 1.7,
|
microsecond: 1.7,
|
||||||
nanosecond: 1.7,
|
nanosecond: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.PlainTime.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.PlainTime.from(argument);
|
|
||||||
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument);
|
|
||||||
TemporalHelpers.assertPlainTime(result, 13, 35, 57, 988, 655, 322);
|
TemporalHelpers.assertPlainTime(result, 13, 35, 57, 988, 655, 322);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument);
|
|
||||||
TemporalHelpers.assertPlainTime(result, 11, 33, 55, 986, 653, 320);
|
TemporalHelpers.assertPlainTime(result, 11, 33, 55, 986, 653, 320);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,51 +10,37 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get timeZone",
|
"get fields.timeZone",
|
||||||
"get hour",
|
"get fields.hour",
|
||||||
"get hour.valueOf",
|
"get fields.hour.valueOf",
|
||||||
"call hour.valueOf",
|
"call fields.hour.valueOf",
|
||||||
"get microsecond",
|
"get fields.microsecond",
|
||||||
"get microsecond.valueOf",
|
"get fields.microsecond.valueOf",
|
||||||
"call microsecond.valueOf",
|
"call fields.microsecond.valueOf",
|
||||||
"get millisecond",
|
"get fields.millisecond",
|
||||||
"get millisecond.valueOf",
|
"get fields.millisecond.valueOf",
|
||||||
"call millisecond.valueOf",
|
"call fields.millisecond.valueOf",
|
||||||
"get minute",
|
"get fields.minute",
|
||||||
"get minute.valueOf",
|
"get fields.minute.valueOf",
|
||||||
"call minute.valueOf",
|
"call fields.minute.valueOf",
|
||||||
"get nanosecond",
|
"get fields.nanosecond",
|
||||||
"get nanosecond.valueOf",
|
"get fields.nanosecond.valueOf",
|
||||||
"call nanosecond.valueOf",
|
"call fields.nanosecond.valueOf",
|
||||||
"get second",
|
"get fields.second",
|
||||||
"get second.valueOf",
|
"get fields.second.valueOf",
|
||||||
"call second.valueOf",
|
"call fields.second.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
hour: 1.7,
|
hour: 1.7,
|
||||||
minute: 1.7,
|
minute: 1.7,
|
||||||
second: 1.7,
|
second: 1.7,
|
||||||
millisecond: 1.7,
|
millisecond: 1.7,
|
||||||
microsecond: 1.7,
|
microsecond: 1.7,
|
||||||
nanosecond: 1.7,
|
nanosecond: 1.7,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.with(argument);
|
|
||||||
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
|
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -9,36 +9,24 @@ features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = Temporal.PlainYearMonth.from(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
||||||
const result = target[key];
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = Temporal.PlainYearMonth.from(argument);
|
|
||||||
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
|
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -14,23 +14,11 @@ features: [Temporal]
|
||||||
|
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const expected = [
|
const expected = [
|
||||||
"get extra",
|
"ownKeys options",
|
||||||
"get overflow",
|
"get options.extra",
|
||||||
|
"get options.overflow",
|
||||||
];
|
];
|
||||||
const options = new Proxy({ extra: 5 }, {
|
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
class CustomCalendar extends Temporal.Calendar {
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -14,27 +14,15 @@ features: [Temporal]
|
||||||
|
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const expected = [
|
const expected = [
|
||||||
"get overflow",
|
"ownKeys options",
|
||||||
"get overflow",
|
"get options.overflow",
|
||||||
"get overflow.toString",
|
"get options.overflow",
|
||||||
"call overflow.toString",
|
"get options.overflow.toString",
|
||||||
"get overflow.toString",
|
"call options.overflow.toString",
|
||||||
"call overflow.toString",
|
"get options.overflow.toString",
|
||||||
|
"call options.overflow.toString",
|
||||||
];
|
];
|
||||||
const options = new Proxy({ overflow: "constrain" }, {
|
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
class CustomCalendar extends Temporal.Calendar {
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.add(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.add(argument);
|
|
||||||
TemporalHelpers.assertPlainYearMonth(result, 2001, 6, "M06");
|
TemporalHelpers.assertPlainYearMonth(result, 2001, 6, "M06");
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -14,23 +14,11 @@ features: [Temporal]
|
||||||
|
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const expected = [
|
const expected = [
|
||||||
"get extra",
|
"ownKeys options",
|
||||||
"get overflow",
|
"get options.extra",
|
||||||
|
"get options.overflow",
|
||||||
];
|
];
|
||||||
const options = new Proxy({ extra: 5 }, {
|
const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options");
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
class CustomCalendar extends Temporal.Calendar {
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -14,27 +14,15 @@ features: [Temporal]
|
||||||
|
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const expected = [
|
const expected = [
|
||||||
"get overflow",
|
"ownKeys options",
|
||||||
"get overflow",
|
"get options.overflow",
|
||||||
"get overflow.toString",
|
"get options.overflow",
|
||||||
"call overflow.toString",
|
"get options.overflow.toString",
|
||||||
"get overflow.toString",
|
"call options.overflow.toString",
|
||||||
"call overflow.toString",
|
"get options.overflow.toString",
|
||||||
|
"call options.overflow.toString",
|
||||||
];
|
];
|
||||||
const options = new Proxy({ overflow: "constrain" }, {
|
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
class CustomCalendar extends Temporal.Calendar {
|
class CustomCalendar extends Temporal.Calendar {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -10,39 +10,39 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get days",
|
"get fields.days",
|
||||||
"get days.valueOf",
|
"get fields.days.valueOf",
|
||||||
"call days.valueOf",
|
"call fields.days.valueOf",
|
||||||
"get hours",
|
"get fields.hours",
|
||||||
"get hours.valueOf",
|
"get fields.hours.valueOf",
|
||||||
"call hours.valueOf",
|
"call fields.hours.valueOf",
|
||||||
"get microseconds",
|
"get fields.microseconds",
|
||||||
"get microseconds.valueOf",
|
"get fields.microseconds.valueOf",
|
||||||
"call microseconds.valueOf",
|
"call fields.microseconds.valueOf",
|
||||||
"get milliseconds",
|
"get fields.milliseconds",
|
||||||
"get milliseconds.valueOf",
|
"get fields.milliseconds.valueOf",
|
||||||
"call milliseconds.valueOf",
|
"call fields.milliseconds.valueOf",
|
||||||
"get minutes",
|
"get fields.minutes",
|
||||||
"get minutes.valueOf",
|
"get fields.minutes.valueOf",
|
||||||
"call minutes.valueOf",
|
"call fields.minutes.valueOf",
|
||||||
"get months",
|
"get fields.months",
|
||||||
"get months.valueOf",
|
"get fields.months.valueOf",
|
||||||
"call months.valueOf",
|
"call fields.months.valueOf",
|
||||||
"get nanoseconds",
|
"get fields.nanoseconds",
|
||||||
"get nanoseconds.valueOf",
|
"get fields.nanoseconds.valueOf",
|
||||||
"call nanoseconds.valueOf",
|
"call fields.nanoseconds.valueOf",
|
||||||
"get seconds",
|
"get fields.seconds",
|
||||||
"get seconds.valueOf",
|
"get fields.seconds.valueOf",
|
||||||
"call seconds.valueOf",
|
"call fields.seconds.valueOf",
|
||||||
"get weeks",
|
"get fields.weeks",
|
||||||
"get weeks.valueOf",
|
"get fields.weeks.valueOf",
|
||||||
"call weeks.valueOf",
|
"call fields.weeks.valueOf",
|
||||||
"get years",
|
"get fields.years",
|
||||||
"get years.valueOf",
|
"get fields.years.valueOf",
|
||||||
"call years.valueOf",
|
"call fields.years.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
years: 1,
|
years: 1,
|
||||||
months: 1,
|
months: 1,
|
||||||
weeks: 1,
|
weeks: 1,
|
||||||
|
@ -53,22 +53,8 @@ const fields = {
|
||||||
milliseconds: 1,
|
milliseconds: 1,
|
||||||
microseconds: 1,
|
microseconds: 1,
|
||||||
nanoseconds: 1,
|
nanoseconds: 1,
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.subtract(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.subtract(argument);
|
|
||||||
TemporalHelpers.assertPlainYearMonth(result, 1999, 4, "M04");
|
TemporalHelpers.assertPlainYearMonth(result, 1999, 4, "M04");
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
|
@ -10,39 +10,25 @@ features: [Temporal]
|
||||||
|
|
||||||
const instance = new Temporal.PlainYearMonth(2000, 5);
|
const instance = new Temporal.PlainYearMonth(2000, 5);
|
||||||
const expected = [
|
const expected = [
|
||||||
"get calendar",
|
"get fields.calendar",
|
||||||
"get timeZone",
|
"get fields.timeZone",
|
||||||
"get month",
|
"get fields.month",
|
||||||
"get month.valueOf",
|
"get fields.month.valueOf",
|
||||||
"call month.valueOf",
|
"call fields.month.valueOf",
|
||||||
"get monthCode",
|
"get fields.monthCode",
|
||||||
"get monthCode.toString",
|
"get fields.monthCode.toString",
|
||||||
"call monthCode.toString",
|
"call fields.monthCode.toString",
|
||||||
"get year",
|
"get fields.year",
|
||||||
"get year.valueOf",
|
"get fields.year.valueOf",
|
||||||
"call year.valueOf",
|
"call fields.year.valueOf",
|
||||||
];
|
];
|
||||||
const actual = [];
|
const actual = [];
|
||||||
const fields = {
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
||||||
year: 1.7,
|
year: 1.7,
|
||||||
month: 1.7,
|
month: 1.7,
|
||||||
monthCode: "M01",
|
monthCode: "M01",
|
||||||
};
|
}, "fields");
|
||||||
const argument = new Proxy(fields, {
|
const result = instance.with(fields);
|
||||||
get(target, key) {
|
|
||||||
actual.push(`get ${key}`);
|
|
||||||
const result = target[key];
|
|
||||||
if (result === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
||||||
},
|
|
||||||
has(target, key) {
|
|
||||||
actual.push(`has ${key}`);
|
|
||||||
return key in target;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const result = instance.with(argument);
|
|
||||||
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
|
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
|
||||||
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
||||||
assert.compareArray(actual, expected, "order of operations");
|
assert.compareArray(actual, expected, "order of operations");
|
||||||
|
|
Loading…
Reference in New Issue