From aee3a937dc7e7a4d5d69dc40a5327a0908875a92 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 17 Jan 2023 11:23:57 -0800 Subject: [PATCH] Change Temporal.Calendar compare semantics to use .id Compare semantics for custom calendars that _don't_ extend Temporal.Calendar (and therefore don't have the internal slot) use the value of the .id property, instead of calling toString(). Normative PR: https://github.com/tc39/proposal-temporal/pull/2482 --- harness/temporalHelpers.js | 3 ++- .../prototype/equals/argument-object-valid.js | 2 +- .../prototype/equals/argument-string.js | 2 +- .../equals/calendar-call-different.js | 16 +++++++----- .../prototype/equals/calendar-call-same.js | 10 ++++--- .../prototype/since/calendar-mismatch.js | 6 ++--- .../prototype/since/order-of-operations.js | 8 ++---- .../prototype/toString/calendar-tostring.js | 10 ++++--- .../prototype/toString/calendarname-always.js | 8 +++--- .../prototype/toString/calendarname-auto.js | 8 +++--- .../toString/calendarname-critical.js | 8 +++--- .../prototype/toString/calendarname-never.js | 8 +++--- .../toString/calendarname-undefined.js | 8 +++--- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/options-undefined.js | 2 +- .../prototype/toString/order-of-operations.js | 4 +-- .../prototype/until/calendar-mismatch.js | 6 ++--- .../prototype/until/order-of-operations.js | 8 ++---- .../prototype/equals/calendar-checked.js | 26 ++++++++++++++----- .../since/different-calendars-throws.js | 2 +- .../prototype/since/order-of-operations.js | 8 ++---- .../prototype/toString/calendar-tostring.js | 10 ++++--- .../prototype/toString/calendarname-always.js | 8 +++--- .../prototype/toString/calendarname-auto.js | 8 +++--- .../toString/calendarname-critical.js | 8 +++--- .../prototype/toString/calendarname-never.js | 8 +++--- .../toString/calendarname-undefined.js | 8 +++--- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/options-undefined.js | 2 +- .../prototype/toString/order-of-operations.js | 8 ++---- .../until/different-calendars-throws.js | 2 +- .../prototype/until/order-of-operations.js | 8 ++---- .../argument-plaindate-calendar-same-id.js | 7 ++--- .../prototype/equals/calendars.js | 11 ++++---- .../prototype/toJSON/calendarname.js | 8 +++--- .../prototype/toJSON/year-format.js | 2 +- .../prototype/toString/calendar-tostring.js | 10 ++++--- .../prototype/toString/calendarname-always.js | 8 +++--- .../prototype/toString/calendarname-auto.js | 8 +++--- .../toString/calendarname-critical.js | 8 +++--- .../prototype/toString/calendarname-never.js | 8 +++--- .../toString/calendarname-undefined.js | 8 +++--- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/options-undefined.js | 8 +++--- .../prototype/toString/order-of-operations.js | 4 +-- .../prototype/toString/year-format.js | 2 +- .../prototype/equals/compare-calendar.js | 7 +++-- .../prototype/since/mixed-calendar-invalid.js | 4 +-- .../prototype/since/order-of-operations.js | 8 ++---- .../prototype/toString/calendar-tostring.js | 10 ++++--- .../prototype/toString/calendarname-always.js | 8 +++--- .../prototype/toString/calendarname-auto.js | 8 +++--- .../toString/calendarname-critical.js | 8 +++--- .../prototype/toString/calendarname-never.js | 8 +++--- .../toString/calendarname-undefined.js | 8 +++--- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/options-undefined.js | 2 +- .../prototype/toString/order-of-operations.js | 4 +-- .../prototype/until/mixed-calendar-invalid.js | 4 +-- .../prototype/until/order-of-operations.js | 8 ++---- .../prototype/equals/order-of-operations.js | 8 ++---- .../prototype/since/order-of-operations.js | 8 ++---- .../prototype/toString/calendar-tostring.js | 10 ++++--- .../prototype/toString/calendarname-always.js | 8 +++--- .../prototype/toString/calendarname-auto.js | 8 +++--- .../toString/calendarname-critical.js | 8 +++--- .../prototype/toString/calendarname-never.js | 8 +++--- .../toString/calendarname-undefined.js | 8 +++--- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/options-undefined.js | 2 +- .../prototype/toString/order-of-operations.js | 8 ++---- .../prototype/until/order-of-operations.js | 8 ++---- .../argument-plaindate-calendar-same-id.js | 7 ++--- ...argument-plaindate-calendar-same-object.js | 7 +++-- .../Temporal/Instant/old/toZonedDateTime.js | 2 +- .../UserCalendar/old/calendar-extra-fields.js | 3 +++ .../old/calendar-non-trivial-mergefields.js | 3 +++ .../old/trivial-protocol-implementation.js | 1 + .../UserTimezone/old/subminute-offset.js | 2 +- .../UserTimezone/old/trivial-protocol.js | 2 +- .../UserTimezone/old/trivial-subclass.js | 2 +- .../old/construction-and-properties.js | 2 +- .../Temporal/ZonedDateTime/old/equals.js | 2 +- .../Temporal/ZonedDateTime/old/since.js | 2 +- .../Temporal/ZonedDateTime/old/toPlainDate.js | 2 +- .../ZonedDateTime/old/toPlainMonthDay.js | 2 +- .../ZonedDateTime/old/toPlainYearMonth.js | 2 +- .../Temporal/ZonedDateTime/old/toString.js | 2 +- .../Temporal/ZonedDateTime/old/until.js | 2 +- .../ZonedDateTime/old/withCalendar.js | 2 +- .../ZonedDateTime/old/withPlainDate.js | 4 +-- .../ZonedDateTime/old/withTimezone.js | 2 +- 92 files changed, 278 insertions(+), 271 deletions(-) diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index a2cd50a13f..c49bc282a6 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -1520,7 +1520,8 @@ var TemporalHelpers = { // Remove the HasProperty check resulting from the above constructor call assert.sameValue(calls.pop(), `has ${objectName}.calendar`); return result; - } + }, + id: "iso8601", }; // Automatically generate the other methods that don't need any custom code ["toString", "dateUntil", "era", "eraYear", "year", "month", "monthCode", "day", "daysInMonth", "fields", "mergeFields"].forEach((methodName) => { diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js index c87e6925d9..6618587e64 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js @@ -11,6 +11,6 @@ const instance = new Temporal.PlainDate(2000, 5, 2); assert.sameValue(instance.equals({ year: 2000, month: 5, day: 2 }), true, "same date"); assert.sameValue(instance.equals({ year: 2000, month: 5, day: 4 }), false, "different date"); -const calendar = { toString() { return "a" } }; +const calendar = { id: "a" }; assert.sameValue(instance.withCalendar(calendar).equals({ year: 2000, month: 5, day: 2 }), false, "different calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js index 85e28ca874..60df5994a4 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js @@ -11,5 +11,5 @@ const instance = new Temporal.PlainDate(2000, 5, 2); assert.sameValue(instance.equals("2000-05-02"), true, "same date"); assert.sameValue(instance.equals("2000-05-04"), false, "different date"); -const calendar = { toString() { return "a" } }; +const calendar = { id: "a" }; assert.sameValue(instance.withCalendar(calendar).equals("2000-05-02"), false, "different calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js index b1e30dd710..66be3ef1ac 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js @@ -4,27 +4,31 @@ /*--- esid: sec-temporal.plaindate.protoype.equals description: test if the calendar is compared +includes: [temporalHelpers.js] features: [Temporal] ---*/ -class CalendarTraceToString extends Temporal.Calendar { +class CalendarTraceId extends Temporal.Calendar { constructor(id) { super("iso8601"); this.id_ = id; this.calls = 0; } - toString() { + get id() { ++this.calls; return this.id_; } + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); + } }; -const calendar1 = new CalendarTraceToString("a"); +const calendar1 = new CalendarTraceId("a"); const date1 = new Temporal.PlainDate(1914, 2, 23, calendar1); -const calendar2 = new CalendarTraceToString("b"); +const calendar2 = new CalendarTraceId("b"); const date2 = new Temporal.PlainDate(1914, 2, 23, calendar2); assert.sameValue(date1.equals(date2), false, "different calendars"); -assert.sameValue(calendar1.calls, 1, "calendar1 toString() calls"); -assert.sameValue(calendar2.calls, 1, "calendar2 toString() calls"); +assert.sameValue(calendar1.calls, 1, "calendar1 id getter calls"); +assert.sameValue(calendar2.calls, 1, "calendar2 id getter calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js index 2fea62c77e..cf38dc08aa 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js @@ -4,6 +4,7 @@ /*--- esid: sec-temporal.plaindate.protoype.equals description: test if the calendar is compared +includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -13,10 +14,13 @@ class CalendarTraceToString extends Temporal.Calendar { this.id_ = id; this.calls = 0; } - toString() { + get id() { ++this.calls; return this.id_; } + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); + } }; const calendar1 = new CalendarTraceToString("a"); @@ -26,5 +30,5 @@ const calendar2 = new CalendarTraceToString("a"); const date2 = new Temporal.PlainDate(1914, 2, 23, calendar2); assert.sameValue(date1.equals(date2), true, "same calendar id"); -assert.sameValue(calendar1.calls, 1, "calendar1 toString() calls"); -assert.sameValue(calendar2.calls, 1, "calendar2 toString() calls"); +assert.sameValue(calendar1.calls, 1, "calendar1 id getter calls"); +assert.sameValue(calendar2.calls, 1, "calendar2 id getter calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js index eabfb22ad7..9aa410c325 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.plaindate.prototype.since -description: RangeError thrown if calendars' toString results do not match +description: RangeError thrown if calendars' id properties do not match features: [Temporal] ---*/ -const calendar1 = { toString() { return "A"; } }; -const calendar2 = { toString() { return "B"; } }; +const calendar1 = { id: "A" }; +const calendar2 = { id: "B" }; const plainDate1 = new Temporal.PlainDate(2000, 1, 1, calendar1); const plainDate2 = new Temporal.PlainDate(2000, 1, 1, calendar2); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index f8731590cd..10d5a02d87 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -29,12 +29,8 @@ const expected = [ "get other.calendar.dateFromFields", "call other.calendar.dateFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js index 7dd8ee3a49..a2f4eea8c8 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js @@ -4,14 +4,18 @@ /*--- esid: sec-temporal.plaindate.protoype.tostring description: Number of observable 'toString' calls on the calendar for each value of calendarName +includes: [temporalHelpers.js] features: [Temporal] ---*/ let calls; const customCalendar = { - toString() { + get id() { ++calls; return "custom"; + }, + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); } }; const date = new Temporal.PlainDate(2000, 5, 2, customCalendar); @@ -24,6 +28,6 @@ const date = new Temporal.PlainDate(2000, 5, 2, customCalendar); ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); + assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js index 607a9f660c..6bfa0bd3f6 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05-02[u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-02[u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-02[u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js index c5154ea8a9..3831f1dbe0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js index 1a2dee0530..3a9b6198f6 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js @@ -11,10 +11,10 @@ features: [Temporal] const tests = [ [[], "2000-05-02[!u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-02[!u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-02[!u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-02[!u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-02[!u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-02[!u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-02[!u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-02[!u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-02[!u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js index 163ab4eb10..cb64db7540 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-02", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-02", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-02", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-02", "custom"], + [[{ id: "iso8601" }], "2000-05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-02", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-02", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js index b6b0c4f685..84c74e6486 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js @@ -16,10 +16,10 @@ features: [Temporal] const tests = [ [[], "2000-05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js index c14aa25a9c..fae8c092a3 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js @@ -16,7 +16,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const date = new Temporal.PlainDate(2000, 5, 2, calendar); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js index 389993ae72..6d466fc084 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const date1 = new Temporal.PlainDate(2000, 5, 2); const date2 = new Temporal.PlainDate(2000, 5, 2, calendar); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js index fa627943c1..a773a9a792 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js @@ -12,9 +12,7 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; const actual = []; diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js index 481fff4f39..47166ce104 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js @@ -3,12 +3,12 @@ /*--- esid: sec-temporal.plaindate.prototype.until -description: RangeError thrown if calendars' toString results do not match +description: RangeError thrown if calendars' id properties do not match features: [Temporal] ---*/ -const calendar1 = { toString() { return "A"; } }; -const calendar2 = { toString() { return "B"; } }; +const calendar1 = { id: "A" }; +const calendar2 = { id: "B" }; const plainDate1 = new Temporal.PlainDate(2000, 1, 1, calendar1); const plainDate2 = new Temporal.PlainDate(2000, 1, 1, calendar2); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index 382a9ed13c..4f92a31b63 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -29,12 +29,8 @@ const expected = [ "get other.calendar.dateFromFields", "call other.calendar.dateFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js index 0fe41c264c..66db938217 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js @@ -9,26 +9,38 @@ features: [Temporal] ---*/ const actual = []; -const calendar1 = TemporalHelpers.toPrimitiveObserver(actual, "A", "calendar1"); -const calendar2 = TemporalHelpers.toPrimitiveObserver(actual, "A", "calendar2"); -const calendar3 = TemporalHelpers.toPrimitiveObserver(actual, "B", "calendar3"); + +function makeCalendar(id, objectName) { + const calendar = {}; + TemporalHelpers.observeProperty(actual, calendar, "id", id, objectName); + return calendar; +} + +const calendar1 = makeCalendar("A", "calendar1"); +const calendar2 = makeCalendar("A", "calendar2"); +const calendar3 = makeCalendar("B", "calendar3"); const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); const dt1b = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); const dt2 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar2); const dt3 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar3); +actual.splice(0); // disregard the HasProperty checks done in the constructor assert.sameValue(dt1.equals(dt1b), true, "same calendar object"); assert.compareArray(actual, []); assert.sameValue(dt1.equals(dt2), true, "same calendar string"); -assert.compareArray(actual, ["get calendar1.toString", "call calendar1.toString", "get calendar2.toString", "call calendar2.toString"]); +assert.compareArray(actual, ["get calendar1.id", "get calendar2.id"]); actual.splice(0); // empty it for the next check assert.sameValue(dt1.equals(dt3), false, "different calendar string"); -assert.compareArray(actual, ["get calendar1.toString", "call calendar1.toString", "get calendar3.toString", "call calendar3.toString"]); +assert.compareArray(actual, ["get calendar1.id", "get calendar3.id"]); -const calendar4 = { toString() { throw new Test262Error("should not call calendar4.toString") } }; -const calendar5 = { toString() { throw new Test262Error("should not call calendar5.toString") } }; +const calendar4 = { + get id() { TemporalHelpers.assertUnreachable('should not get calendar4.id'); }, +}; +const calendar5 = { + get id() { TemporalHelpers.assertUnreachable('should not get calendar5.id'); }, +}; const dt4 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar4); const dt5 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar4); const dt6 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar5); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js index 6312b4748c..ecb03f3ae3 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); -const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, {}); +const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, { id: "custom" }); assert.throws( RangeError, diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index ff3b818c4b..400eb5a335 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -47,12 +47,8 @@ const expected = [ "get other.calendar.dateFromFields", "call other.calendar.dateFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js index 14538ab4cb..6671f1dd42 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js @@ -4,14 +4,18 @@ /*--- esid: sec-temporal.plaindatetime.protoype.tostring description: Number of observable 'toString' calls on the calendar for each value of calendarName +includes: [temporalHelpers.js] features: [Temporal] ---*/ let calls; const customCalendar = { - toString() { + get id() { ++calls; return "custom"; + }, + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); } }; const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, customCalendar); @@ -24,6 +28,6 @@ const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, c ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); + assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js index a66b1995d3..e38c5bf1a7 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1976-11-18T15:23:00[u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00[u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1976-11-18T15:23:00[u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js index c8945caf9b..4886e9e798 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1976-11-18T15:23:00", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js index 69bbe1add4..7bea217a73 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js @@ -11,10 +11,10 @@ features: [Temporal] const tests = [ [[], "1976-11-18T15:23:00[!u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[!u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00[!u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00[!u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00[!u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1976-11-18T15:23:00[!u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1976-11-18T15:23:00[!u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1976-11-18T15:23:00[!u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1976-11-18T15:23:00[!u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js index cd06f152fa..f201e0ffed 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00", "custom"], - [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00", "custom with dotless i toString"], + [[{ id: "custom" }], "1976-11-18T15:23:00", "custom"], + [[{ id: "iso8601" }], "1976-11-18T15:23:00", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1976-11-18T15:23:00", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1976-11-18T15:23:00", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js index 800fac39da..7b56b83dce 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js @@ -16,10 +16,10 @@ features: [Temporal] const tests = [ [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1976-11-18T15:23:00", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js index a452be5bdb..613d0f3d14 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js @@ -16,7 +16,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js index 0f19b561d2..bc8aa6bc84 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const datetime1 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0); const datetime2 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0, calendar); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js index 5596255315..231721be90 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js @@ -21,9 +21,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; const actual = []; @@ -55,9 +53,7 @@ const expectedForFractionalSecondDigits = [ "get options.roundingMode.toString", "call options.roundingMode.toString", "get options.smallestUnit", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; instance.toString( diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js index 1fe7a72191..f5c667a5dc 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); -const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, {}); +const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, { id: "custom" }); assert.throws( RangeError, diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index df5143b24a..ac1ab6fc25 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -47,12 +47,8 @@ const expected = [ "get other.calendar.dateFromFields", "call other.calendar.dateFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js index caf056f49e..3d06dce97e 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js @@ -9,13 +9,14 @@ includes: [temporalHelpers.js] ---*/ const cal1 = { - toString() { return "this is a string"; }, + id: "this is a string", + toString() { return "this is another string"; } }; const cal2 = { - id: 'thisisnotiso', + id: "this is a string", era() { return undefined; }, eraYear() { return undefined; }, - toString() { return "this is a string"; }, + toString() { return "thisisnotiso"; }, year() { return 2008; }, month() { return 9; }, monthCode() { return "M09"; }, diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js index 63b75cf1b1..0ae2a49a3a 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js @@ -9,19 +9,20 @@ features: [Temporal] ---*/ const expected = [ - "get calendar a.toString", - "call calendar a.toString", - "get calendar b.toString", - "call calendar b.toString", + "get calendar a.id", + "get calendar b.id", ]; const actual = []; const calendar = (id) => { - return TemporalHelpers.toPrimitiveObserver(actual, id, `calendar ${id}`); + const c = {}; + TemporalHelpers.observeProperty(actual, c, "id", id, `calendar ${id}`); + return c; }; const mdA = new Temporal.PlainMonthDay(2, 7, calendar("a")); const mdB = new Temporal.PlainMonthDay(2, 7, calendar("b")); const mdC = new Temporal.PlainMonthDay(2, 7, calendar("c"), 1974); +actual.splice(0); // disregard the HasProperty checks done in the constructor assert.sameValue(mdA.equals(mdC), false, "different year"); assert.compareArray(actual, [], "Should not check calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js index a590710d69..c2b26f5cd7 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "05-02"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]"], - [[{ toString() { return "iso8601"; } }], "05-02"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i + [[{ id: "custom" }], "1972-05-02[u-ca=custom]"], + [[{ id: "iso8601" }], "05-02"], + [[{ id: "ISO8601" }], "1972-05-02[u-ca=ISO8601]"], + [[{ id: "\u0131so8601" }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i ]; const options = { get calendarName() { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js index 90b633fb29..ebe40ba173 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js @@ -11,7 +11,7 @@ features: [Temporal] // the calendar is not ISO 8601 class NotISO extends Temporal.Calendar { constructor() { super("iso8601"); } - toString() { return "not-iso"; } + get id() { return "not-iso"; } } const calendar = new NotISO(); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js index 1df2ef8da2..76357fea1f 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js @@ -4,14 +4,18 @@ /*--- esid: sec-temporal.plainmonthday.protoype.tostring description: Number of observable 'toString' calls on the calendar for each value of calendarName +includes: [temporalHelpers.js] features: [Temporal] ---*/ let calls; const customCalendar = { - toString() { + get id() { ++calls; return "custom"; + }, + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); } }; const monthday = new Temporal.PlainMonthDay(5, 2, customCalendar); @@ -24,6 +28,6 @@ const monthday = new Temporal.PlainMonthDay(5, 2, customCalendar); ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = monthday.toString({ calendarName }); - assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); + assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js index df1d606fda..bcffe3ecb5 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1972-05-02[u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1972-05-02[u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1972-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1972-05-02[u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js index 5abf0fa619..414312817c 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1972-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js index f49b6f89ff..06bbb45d6d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js @@ -11,10 +11,10 @@ features: [Temporal] const tests = [ [[], "1972-05-02[!u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1972-05-02[!u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1972-05-02[!u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[!u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[!u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1972-05-02[!u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1972-05-02[!u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1972-05-02[!u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1972-05-02[!u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js index 1fbb89abc7..dc7b3bcc76 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1972-05-02", "custom"], - [[{ toString() { return "iso8601"; } }], "05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02", "custom with dotless i toString"], + [[{ id: "custom" }], "1972-05-02", "custom"], + [[{ id: "iso8601" }], "05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1972-05-02", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1972-05-02", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js index 8fc2cde338..bb93009943 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js @@ -16,10 +16,10 @@ features: [Temporal] const tests = [ [[], "05-02", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "05-02", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1972-05-02[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "05-02", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js index 39328d7e57..4a733f3709 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js @@ -16,7 +16,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const monthday = new Temporal.PlainMonthDay(5, 2, calendar); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js index da53b9a72c..abeafa5a49 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "05-02"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]"], - [[{ toString() { return "iso8601"; } }], "05-02"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i + [[{ id: "custom" }], "1972-05-02[u-ca=custom]"], + [[{ id: "iso8601" }], "05-02"], + [[{ id: "ISO8601" }], "1972-05-02[u-ca=ISO8601]"], + [[{ id: "\u0131so8601" }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i ]; for (const [args, expected] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js index be16b543ed..6bd221d57d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js @@ -12,9 +12,7 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; const actual = []; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js index 3898ff66b6..da4aaeb7cb 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js @@ -11,7 +11,7 @@ features: [Temporal] // the calendar is not ISO 8601 class NotISO extends Temporal.Calendar { constructor() { super("iso8601"); } - toString() { return "not-iso"; } + get id() { return "not-iso"; } } const calendar = new NotISO(); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js index b7bf5dc968..90244edaca 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js @@ -4,7 +4,7 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.equals description: equals() takes the calendar into account -includes: [compareArray.js] +includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ @@ -14,10 +14,13 @@ class CustomCalendar extends Temporal.Calendar { super("iso8601"); this._id = id; } - toString() { + get id() { actual.push(this._id); return this._id; } + toString() { + TemporalHelpers.assertUnreachable("should not call toString"); + } } const sharedCalendar = new CustomCalendar("a"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js index de9ffb8d92..8dfa5fb139 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js @@ -11,8 +11,8 @@ class customCal extends Temporal.Calendar { constructor () { super('iso8601'); } - - toString() { + + get id() { return "I am a secret cal."; } } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 44e5c304a3..917b104137 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -26,12 +26,8 @@ const expected = [ "get other.calendar.yearMonthFromFields", "call other.calendar.yearMonthFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js index 3eec13d779..f054008db7 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js @@ -4,14 +4,18 @@ /*--- esid: sec-temporal.plainyearmonth.protoype.tostring description: Number of observable 'toString' calls on the calendar for each value of calendarName +includes: [temporalHelpers.js] features: [Temporal] ---*/ let calls; const customCalendar = { - toString() { + get id() { ++calls; return "custom"; + }, + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); } }; const yearmonth = new Temporal.PlainYearMonth(2000, 5, customCalendar); @@ -24,6 +28,6 @@ const yearmonth = new Temporal.PlainYearMonth(2000, 5, customCalendar); ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = yearmonth.toString({ calendarName }); - assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); + assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js index 378a056bec..bf4907ce11 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05-01[u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-01[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-01[u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-01[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-01[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-01[u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js index d4e547d215..52403a6e8f 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-01[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-01[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-01[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js index 85e50d262c..9685c5e733 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js @@ -11,10 +11,10 @@ features: [Temporal] const tests = [ [[], "2000-05-01[!u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-01[!u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05-01[!u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-01[!u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-01[!u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-01[!u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05-01[!u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-01[!u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-01[!u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js index 670c0019a7..0025f6cd33 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "2000-05", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-01", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-01", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-01", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-01", "custom"], + [[{ id: "iso8601" }], "2000-05", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-01", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-01", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js index 23592c7d54..de744477c9 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js @@ -16,10 +16,10 @@ features: [Temporal] const tests = [ [[], "2000-05", "built-in ISO"], - [[{ toString() { return "custom"; } }], "2000-05-01[u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "2000-05", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "2000-05-01[u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "2000-05-01[u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "2000-05", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js index 4ad85fe1df..8064a4ebe5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js @@ -16,7 +16,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js index 19b6e8e7b3..65e309b45e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js index 902d57fd5b..95bcf3ff94 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js @@ -12,9 +12,7 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; const actual = []; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js index d971f9faf7..653542e781 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js @@ -11,8 +11,8 @@ class customCal extends Temporal.Calendar { constructor () { super('iso8601'); } - - toString() { + + get id() { return "I am a secret cal."; } } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index e9c93ad41d..9f65ee6a57 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -26,12 +26,8 @@ const expected = [ "get other.calendar.yearMonthFromFields", "call other.calendar.yearMonthFromFields", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js index f45365a849..0556c76ad5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js @@ -65,12 +65,8 @@ const expected = [ "get other.timeZone.toString", "call other.timeZone.toString", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", ]; const actual = []; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index a0e64466f5..ed6d61c00e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -56,12 +56,8 @@ const expected = [ "get other.timeZone.getOffsetNanosecondsFor", "call other.timeZone.getOffsetNanosecondsFor", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js index 8d88548e44..0989026740 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js @@ -4,14 +4,18 @@ /*--- esid: sec-temporal.zoneddatetime.protoype.tostring description: Number of observable 'toString' calls on the calendar for each value of calendarName +includes: [temporalHelpers.js] features: [Temporal] ---*/ let calls; const customCalendar = { - toString() { + get id() { ++calls; return "custom"; + }, + toString() { + TemporalHelpers.assertUnreachable('toString should not be called'); } }; const date = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", customCalendar); @@ -24,6 +28,6 @@ const date = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", custo ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); + assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js index 6deb4cfaa8..ae6ae4e75d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js index fef22aebac..9ed61ba254 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js index cd1742d82d..e91ff1089c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js @@ -11,10 +11,10 @@ features: [Temporal] const tests = [ [[], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js index 621c8a8c8e..5dcd599d56 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js @@ -9,10 +9,10 @@ features: [Temporal] const tests = [ [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom"], - [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with dotless i toString"], + [[{ id: "custom" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom"], + [[{ id: "iso8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js index 3464bc79c2..3f450028ce 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js @@ -16,10 +16,10 @@ features: [Temporal] const tests = [ [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 toString"], - [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps toString"], - [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i toString"], + [[{ id: "custom" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], + [[{ id: "iso8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], + [[{ id: "ISO8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], + [[{ id: "\u0131so8601" }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], ]; for (const [args, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js index 14e15ecd2a..7bf6434b56 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js @@ -16,7 +16,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js index 4d5280cbf0..e959cf114c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const calendar = { - toString() { return "custom"; } + id: "custom", }; const datetime1 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC"); const datetime2 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC", calendar); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js index 9c11a5cd9d..08535d27ac 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js @@ -34,9 +34,7 @@ const expected = [ "get this.timeZone[Symbol.toPrimitive]", "get this.timeZone.toString", "call this.timeZone.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; const actual = []; @@ -84,9 +82,7 @@ const expectedForFractionalSecondDigits = [ "get this.timeZone[Symbol.toPrimitive]", "get this.timeZone.toString", "call this.timeZone.toString", - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", + "get this.calendar.id", ]; instance.toString( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index e325000ea1..1a5fa9e6e0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -56,12 +56,8 @@ const expected = [ "get other.timeZone.getOffsetNanosecondsFor", "call other.timeZone.getOffsetNanosecondsFor", // CalendarEquals - "get this.calendar[Symbol.toPrimitive]", - "get this.calendar.toString", - "call this.calendar.toString", - "get other.calendar[Symbol.toPrimitive]", - "get other.calendar.toString", - "call other.calendar.toString", + "get this.calendar.id", + "get other.calendar.id", // CopyDataProperties "ownKeys options", "getOwnPropertyDescriptor options.roundingIncrement", diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js index 7145442005..9e690ec5f0 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js @@ -9,13 +9,14 @@ includes: [temporalHelpers.js] ---*/ const cal1 = { - toString() { return "this is a string"; }, + id: "this is a string", + toString() { return "this is a another string"; }, }; const cal2 = { - id: 'thisisnotiso', + id: "this is a string", era() { return "the era"; }, eraYear() { return 1909; }, - toString() { return "this is a string"; }, + toString() { return "thisisnotiso"; }, year() { return 2008; }, month() { return 9; }, monthCode() { return "M09"; }, diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js index d82e2b9444..8f505ad8b7 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js @@ -10,7 +10,10 @@ includes: [temporalHelpers.js] let calls = 0; const cal = { - id: 'thisisnotiso', + get id() { + ++calls; + return "thisisnotiso"; + }, era() { return "the era"; }, eraYear() { return 1909; }, toString() { @@ -39,4 +42,4 @@ assert.sameValue( cal, "calendar is unchanged with same calendars (2)" ); -assert.sameValue(calls, 0, "should not have called cal.toString()"); +assert.sameValue(calls, 0, "should not have called cal.toString() or accessed cal.id"); diff --git a/test/staging/Temporal/Instant/old/toZonedDateTime.js b/test/staging/Temporal/Instant/old/toZonedDateTime.js index 2569beaf0f..f7fa59fc28 100644 --- a/test/staging/Temporal/Instant/old/toZonedDateTime.js +++ b/test/staging/Temporal/Instant/old/toZonedDateTime.js @@ -15,7 +15,7 @@ assert.throws(TypeError, () => inst.toZonedDateTime()); // throws with a string parameter assert.throws(TypeError, () => inst.toZonedDateTime("UTC")); -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: "gregory" }; // time zone parameter UTC var timeZone = Temporal.TimeZone.from("UTC"); diff --git a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js b/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js index 9e35386d10..669bcc21d2 100644 --- a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js +++ b/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js @@ -11,6 +11,9 @@ class SeasonCalendar extends Temporal.Calendar { constructor() { super("iso8601"); } + get id() { + return "season"; + } toString() { return "season"; } diff --git a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js b/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js index 3a1b8809c4..8c41d56b7b 100644 --- a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js +++ b/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js @@ -11,6 +11,9 @@ class CenturyCalendar extends Temporal.Calendar { constructor() { super("iso8601"); } + get id() { + return 'century'; + } toString() { return "century"; } diff --git a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js index f582ca8431..13585f5555 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js @@ -37,6 +37,7 @@ function isoToDecimal(date) { }; } var obj = { + id: 'decimal', toString() { return "decimal"; }, diff --git a/test/staging/Temporal/UserTimezone/old/subminute-offset.js b/test/staging/Temporal/UserTimezone/old/subminute-offset.js index 5b17b90a19..6f55e3bceb 100644 --- a/test/staging/Temporal/UserTimezone/old/subminute-offset.js +++ b/test/staging/Temporal/UserTimezone/old/subminute-offset.js @@ -50,7 +50,7 @@ assert.throws(RangeError, () => Temporal.TimeZone.from("2020-05-26T16:02:46.2511 assert.sameValue(obj.getOffsetStringFor(inst), "-00:00:01.111111111") // converts to DateTime -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: "gregory" }; assert.sameValue(`${ obj.getPlainDateTimeFor(inst) }`, "1969-12-31T23:59:58.888888889"); assert.sameValue(`${ obj.getPlainDateTimeFor(inst, fakeGregorian) }`, "1969-12-31T23:59:58.888888889[u-ca=gregory]"); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js b/test/staging/Temporal/UserTimezone/old/trivial-protocol.js index c4059ad3b2..44de9bbfee 100644 --- a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js +++ b/test/staging/Temporal/UserTimezone/old/trivial-protocol.js @@ -32,7 +32,7 @@ var zdt = new Temporal.ZonedDateTime(0n, obj); assert.sameValue(zdt.toString(), "1970-01-01T00:00:00+00:00[Etc/Custom/UTC_Protocol]"); // works in Temporal.Now -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: "gregory" }; assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); assert(Temporal.Now.plainDateTime(fakeGregorian, obj) instanceof Temporal.PlainDateTime); assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js index 4e1e84c0ae..bf97d6f4d1 100644 --- a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js +++ b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js @@ -88,7 +88,7 @@ assert.throws(RangeError, () => Temporal.TimeZone.from("2020-05-26T16:02:46.2511 assert.sameValue(obj.getOffsetStringFor(inst), "+00:00") // converts to DateTime -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: "gregory" }; assert.sameValue(`${ obj.getPlainDateTimeFor(inst) }`, "1970-01-01T00:00:00"); assert.sameValue(`${ obj.getPlainDateTimeFor(inst, fakeGregorian) }`, "1970-01-01T00:00:00[u-ca=gregory]"); diff --git a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js index 24a486ce36..9fb60cfedc 100644 --- a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js +++ b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js @@ -66,7 +66,7 @@ var fakeGregorian = { daysInYear(date) { return date.withCalendar("iso8601").daysInYear; }, monthsInYear(date) { return date.withCalendar("iso8601").monthsInYear; }, inLeapYear(date) { return date.withCalendar("iso8601").inLeapYear; }, - toString() { return "gregory"; }, + id: "gregory", }; var fakeVienna = { getOffsetNanosecondsFor() { return 3600_000_000_000; }, diff --git a/test/staging/Temporal/ZonedDateTime/old/equals.js b/test/staging/Temporal/ZonedDateTime/old/equals.js index f6e831afc8..ac6e17f85d 100644 --- a/test/staging/Temporal/ZonedDateTime/old/equals.js +++ b/test/staging/Temporal/ZonedDateTime/old/equals.js @@ -13,7 +13,7 @@ var tz = { }; var cal = { dateFromFields(...args) { return Temporal.Calendar.from("iso8601").dateFromFields(...args); }, - toString() { return "gregory"; }, + id: "gregory", fields(fieldNames) { return fieldNames; }, }; var zdt = new Temporal.ZonedDateTime(0n, tz, cal); diff --git a/test/staging/Temporal/ZonedDateTime/old/since.js b/test/staging/Temporal/ZonedDateTime/old/since.js index 028d4df4e6..baf3462334 100644 --- a/test/staging/Temporal/ZonedDateTime/old/since.js +++ b/test/staging/Temporal/ZonedDateTime/old/since.js @@ -87,7 +87,7 @@ assert.notSameValue(monthsDifference.months, 0); // no two different calendars var zdt1 = new Temporal.ZonedDateTime(0n, "UTC"); -var fakeJapanese = { toString() { return "japanese"; }}; +var fakeJapanese = { id: "japanese" }; var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", fakeJapanese); assert.throws(RangeError, () => zdt1.since(zdt2)); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js index f0b5480691..60b03d2bda 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js @@ -14,7 +14,7 @@ var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTim assert.sameValue(`${ zdt.toPlainDate() }`, "2019-10-29"); // preserves the calendar -const fakeGregorian = { toString() { return "gregory" }}; +const fakeGregorian = { id: 'gregory' }; var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ timeZone: tz, calendar: fakeGregorian diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js b/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js index c25f146f4a..4a6433aa41 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js @@ -15,6 +15,7 @@ assert.sameValue(`${ zdt.toPlainMonthDay() }`, "10-29"); // preserves the calendar var fakeGregorian = { + id: 'gregory', monthDayFromFields(fields) { var md = Temporal.Calendar.from("iso8601").monthDayFromFields(fields); var {isoYear, isoMonth, isoDay} = md.getISOFields(); @@ -22,7 +23,6 @@ var fakeGregorian = { }, monthCode(date) { return date.withCalendar("iso8601").monthCode; }, day(date) { return date.withCalendar("iso8601").day; }, - toString() { return "gregory"; }, fields(fieldNames) { return fieldNames; }, }; var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js b/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js index 09f1720390..1e3e4d1ae3 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js @@ -15,6 +15,7 @@ assert.sameValue(`${ zdt.toPlainYearMonth() }`, "2019-10"); // preserves the calendar var fakeGregorian = { + id: 'gregory', yearMonthFromFields(fields) { var ym = Temporal.Calendar.from("iso8601").yearMonthFromFields(fields); var {isoYear, isoMonth, isoDay} = ym.getISOFields(); @@ -22,7 +23,6 @@ var fakeGregorian = { }, year(date) { return date.withCalendar("iso8601").year; }, monthCode(date) { return date.withCalendar("iso8601").monthCode; }, - toString() { return "gregory"; }, fields(fieldNames) { return fieldNames; }, }; var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ diff --git a/test/staging/Temporal/ZonedDateTime/old/toString.js b/test/staging/Temporal/ZonedDateTime/old/toString.js index 7703f05e7b..d142a0ecf4 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toString.js +++ b/test/staging/Temporal/ZonedDateTime/old/toString.js @@ -9,7 +9,7 @@ features: [Temporal] ---*/ var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); -var fakeGregorian = { toString() { return "gregory" }}; +var fakeGregorian = { id: "gregory" }; // shows offset if offset = auto assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); diff --git a/test/staging/Temporal/ZonedDateTime/old/until.js b/test/staging/Temporal/ZonedDateTime/old/until.js index 876af409d2..10f9cbc196 100644 --- a/test/staging/Temporal/ZonedDateTime/old/until.js +++ b/test/staging/Temporal/ZonedDateTime/old/until.js @@ -87,7 +87,7 @@ assert.notSameValue(monthsDifference.months, 0); // no two different calendars var zdt1 = new Temporal.ZonedDateTime(0n, "UTC"); -var fakeJapanese = { toString() { return "japanese"; }}; +var fakeJapanese = { id: "japanese" }; var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", fakeJapanese); assert.throws(RangeError, () => zdt1.until(zdt2)); diff --git a/test/staging/Temporal/ZonedDateTime/old/withCalendar.js b/test/staging/Temporal/ZonedDateTime/old/withCalendar.js index 3abd2a0aab..bf14cf97aa 100644 --- a/test/staging/Temporal/ZonedDateTime/old/withCalendar.js +++ b/test/staging/Temporal/ZonedDateTime/old/withCalendar.js @@ -10,7 +10,7 @@ features: [Temporal] var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789-08:00[-08:00]"); // zonedDateTime.withCalendar(japanese) works -var cal = { toString() { return "japanese"; }}; +var cal = { id: 'japanese', toString() { return 'japanese'; } }; assert.sameValue(`${ zdt.withCalendar(cal) }`, "2019-11-18T15:23:30.123456789-08:00[-08:00][u-ca=japanese]"); // keeps instant and time zone the same diff --git a/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js index 9131a4f706..5aad741305 100644 --- a/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js +++ b/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js @@ -27,7 +27,7 @@ assert.sameValue(`${ zdt.withPlainDate(date) }`, "2020-01-23T03:24:30-08:00[Cust assert.sameValue(`${ zdt.withPlainDate("2018-09-15") }`, "2018-09-15T03:24:30-08:00[Custom/Spring_Fall]"); // result contains a non-ISO calendar if present in the input -var fakeJapanese = { toString() { return "japanese"; }}; +var fakeJapanese = { id: "japanese" }; assert.sameValue(`${ zdt.withCalendar(fakeJapanese).withPlainDate("2008-09-06") }`, "2008-09-06T03:24:30-08:00[Custom/Spring_Fall][u-ca=japanese]"); // calendar is unchanged if input has ISO calendar @@ -35,7 +35,7 @@ var date = new Temporal.PlainDate(2008, 9, 6, fakeJapanese); assert.sameValue(`${ zdt.withPlainDate(date) }`, "2008-09-06T03:24:30-08:00[Custom/Spring_Fall][u-ca=japanese]"); // throws if both `this` and `other` have a non-ISO calendar -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: "gregory" }; assert.throws(RangeError, () => zdt.withCalendar(fakeGregorian).withPlainDate(date)); // object must contain at least one correctly-spelled property diff --git a/test/staging/Temporal/ZonedDateTime/old/withTimezone.js b/test/staging/Temporal/ZonedDateTime/old/withTimezone.js index 8effe38a75..af57f3370b 100644 --- a/test/staging/Temporal/ZonedDateTime/old/withTimezone.js +++ b/test/staging/Temporal/ZonedDateTime/old/withTimezone.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ // keeps instant and calendar the same -var fakeGregorian = { toString() { return "gregory"; }}; +var fakeGregorian = { id: 'gregory' }; var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]").withCalendar(fakeGregorian); var zdt2 = zdt.withTimeZone("-08:00"); assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);