From 0fc42035eba54e9fdd19ea713ddc171ebb356877 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 19 Oct 2022 09:31:35 -0700 Subject: [PATCH] Temporal: Update tests to use internal slot in TimeZone and Calendar.id In https://github.com/tc39/proposal-temporal/pull/2411, to be proposed for consensus in TC39 in December, the .id getter of TimeZone and Calendar should no longer call toString(). --- .../TimeZone/prototype/id/custom-timezone.js | 10 +++----- .../TimeZone/prototype/id/no-toString.js | 25 ------------------- .../UserCalendar/old/trivial-subclass.js | 3 +++ .../UserTimezone/old/subminute-offset.js | 3 +++ .../UserTimezone/old/trivial-subclass.js | 3 +++ 5 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/id/no-toString.js diff --git a/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js b/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js index 1ea8713ab2..863dc84fac 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js +++ b/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js @@ -3,17 +3,13 @@ /*--- esid: sec-get-temporal.timezone.prototype.id -description: Getter calls toString() and returns its value +description: Getter does not call toString(), returns the ID from internal slot includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ const actual = []; -const expected = [ - "get [Symbol.toPrimitive]", - "get toString", - "call timeZone.toString", -]; +const expected = []; const timeZone = new Temporal.TimeZone("UTC"); TemporalHelpers.observeProperty(actual, timeZone, Symbol.toPrimitive, undefined); @@ -24,4 +20,4 @@ TemporalHelpers.observeProperty(actual, timeZone, "toString", function () { const result = timeZone.id; assert.compareArray(actual, expected); -assert.sameValue(result, "time zone"); +assert.sameValue(result, "UTC"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/id/no-toString.js b/test/built-ins/Temporal/TimeZone/prototype/id/no-toString.js deleted file mode 100644 index ae849b0f83..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/id/no-toString.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.timezone.prototype.id -description: TypeError thrown when toString property not present -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "get timeZone.toString", -]; - -const timeZone = new Temporal.TimeZone("UTC"); -Object.defineProperty(timeZone, "toString", { - get() { - actual.push("get timeZone.toString"); - return undefined; - }, -}); - -assert.throws(TypeError, () => timeZone.id); -assert.compareArray(actual, expected); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js index e123c4f026..32703b7010 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js @@ -11,6 +11,9 @@ class TwoBasedCalendar extends Temporal.Calendar { constructor() { super("iso8601"); } + get id() { + return "two-based"; + } toString() { return "two-based"; } diff --git a/test/staging/Temporal/UserTimezone/old/subminute-offset.js b/test/staging/Temporal/UserTimezone/old/subminute-offset.js index 20d4d34ee3..5b17b90a19 100644 --- a/test/staging/Temporal/UserTimezone/old/subminute-offset.js +++ b/test/staging/Temporal/UserTimezone/old/subminute-offset.js @@ -11,6 +11,9 @@ class SubminuteTimeZone extends Temporal.TimeZone { constructor() { super("-00:00:01.111111111"); } + get id() { + return "Custom/Subminute"; + } toString() { return "Custom/Subminute"; } diff --git a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js index 7e536bbebc..4e1e84c0ae 100644 --- a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js +++ b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js @@ -11,6 +11,9 @@ class CustomUTCSubclass extends Temporal.TimeZone { constructor() { super("UTC"); } + get id() { + return "Etc/Custom/UTC_Subclass"; + } toString() { return "Etc/Custom/UTC_Subclass"; }