Temporal: Expand order-of-operations tests to cover options bags

Some of the existing order-of-operations tests didn't pass an options bag:
primarily from(), with(), add() and subtract(). (since() and until() were
covered in a previous commit.)

Add a TemporalHelpers.propertyBagObserver() options bag to the invocations
of these methods in the order-of-operations tests.
This commit is contained in:
Philip Chimento 2022-11-03 17:46:53 -07:00 committed by Ms2ger
parent e1d46f7fdc
commit ed32b59bba
16 changed files with 162 additions and 47 deletions

View File

@ -22,6 +22,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.dateFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -30,7 +34,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
monthCode: "M01",
day: 1.7,
}, "fields");
const result = Temporal.PlainDate.from(fields);
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
const result = Temporal.PlainDate.from(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,10 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +58,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.add(fields);
TemporalHelpers.assertPlainDate(result, 2001, 6, "M06", 10);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, {
overflow: "constrain",
}, "options");
instance.add(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,10 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +58,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.subtract(fields);
TemporalHelpers.assertPlainDate(result, 1999, 3, "M03", 25);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, {
overflow: "constrain",
}, "options");
instance.subtract(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -24,6 +24,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.dateFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -32,7 +36,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
monthCode: "M01",
day: 1.7,
}, "fields");
const result = instance.with(fields);
TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, {
overflow: "constrain",
}, "options");
instance.with(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,14 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
// inside Calendar.p.dateFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +62,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microsecond: 1.7,
nanosecond: 1.7,
}, "fields");
const result = Temporal.PlainDateTime.from(fields);
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
Temporal.PlainDateTime.from(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,10 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +58,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.add(fields);
TemporalHelpers.assertPlainDateTime(result, 2001, 6, "M06", 10, 13, 35, 57, 988, 655, 322);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.add(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,10 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +58,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.subtract(fields);
TemporalHelpers.assertPlainDateTime(result, 1999, 3, "M03", 25, 11, 33, 55, 986, 653, 320);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.subtract(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -42,6 +42,14 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// InterpretTemporalDateTimeFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
// inside Calendar.p.dateFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -56,7 +64,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microsecond: 1.7,
nanosecond: 1.7,
}, "fields");
const result = instance.with(fields);
TemporalHelpers.assertPlainDateTime(result, 1, 1, "M01", 1, 1, 1, 1, 1, 1, 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.with(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -22,6 +22,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.monthDayFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -30,7 +34,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
monthCode: "M01",
day: 1.7,
}, "fields");
const result = Temporal.PlainMonthDay.from(fields);
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
Temporal.PlainMonthDay.from(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -24,6 +24,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.monthDayFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -32,6 +36,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
monthCode: "M01",
day: 1.7,
}, "fields");
const result = instance.with(fields);
TemporalHelpers.assertPlainMonthDay(result, "M01", 1);
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.with(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -9,6 +9,9 @@ features: [Temporal]
---*/
const expected = [
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
"get fields.calendar",
"get fields.hour",
"get fields.hour.valueOf",
@ -38,7 +41,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microsecond: 1.7,
nanosecond: 1.7,
}, "fields");
const result = Temporal.PlainTime.from(fields);
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, {
overflow: "constrain",
}, "options");
const result = Temporal.PlainTime.from(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -10,8 +10,10 @@ features: [Temporal]
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const expected = [
// RejectObjectWithCalendarOrTimeZone
"get fields.calendar",
"get fields.timeZone",
// ToTemporalTimeRecord
"get fields.hour",
"get fields.hour.valueOf",
"call fields.hour.valueOf",
@ -30,8 +32,13 @@ const expected = [
"get fields.second",
"get fields.second.valueOf",
"call fields.second.valueOf",
// ToTemporalOverflow
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
hour: 1.7,
minute: 1.7,
@ -40,7 +47,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microsecond: 1.7,
nanosecond: 1.7,
}, "fields");
const result = instance.with(fields);
TemporalHelpers.assertPlainTime(result, 1, 1, 1, 1, 1, 1);
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, {
overflow: "constrain",
}, "options");
const result = instance.with(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -19,6 +19,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.yearMonthFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -26,7 +30,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
month: 1.7,
monthCode: "M01",
}, "fields");
const result = Temporal.PlainYearMonth.from(fields);
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
Temporal.PlainYearMonth.from(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,17 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// CopyDataProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +65,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.add(fields);
TemporalHelpers.assertPlainYearMonth(result, 2001, 6, "M06");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.add(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -40,6 +40,17 @@ const expected = [
"get fields.years",
"get fields.years.valueOf",
"call fields.years.valueOf",
// CopyDataProperties
"ownKeys options",
"getOwnPropertyDescriptor options.overflow",
"get options.overflow",
// inside Calendar.p.dateAdd
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
// inside Calendar.p.yearMonthFromFields
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -54,7 +65,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
microseconds: 1,
nanoseconds: 1,
}, "fields");
const result = instance.subtract(fields);
TemporalHelpers.assertPlainYearMonth(result, 1999, 4, "M04");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.subtract(fields, options);
assert.compareArray(actual, expected, "order of operations");

View File

@ -21,6 +21,10 @@ const expected = [
"get fields.year",
"get fields.year.valueOf",
"call fields.year.valueOf",
// inside Calendar.p.yearMonthFromFields
"get options.overflow",
"get options.overflow.toString",
"call options.overflow.toString",
];
const actual = [];
const fields = TemporalHelpers.propertyBagObserver(actual, {
@ -28,7 +32,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, {
month: 1.7,
monthCode: "M01",
}, "fields");
const result = instance.with(fields);
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options");
instance.with(fields, options);
assert.compareArray(actual, expected, "order of operations");