Skip to content

Commit

Permalink
Change Temporal.TimeZone.prototype.toJSON not to call toString
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Feb 18, 2023
1 parent adf2e1c commit 87ed3b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@

/*---
esid: sec-temporal.timezone.prototype.tojson
description: toJSON() calls toString() and returns its value
description: toJSON() returns the internal slot value
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/

const actual = [];
const expected = [
'get [Symbol.toPrimitive]',
'get toString',
'call timeZone.toString',
];

const timeZone = new Temporal.TimeZone("UTC");
TemporalHelpers.observeProperty(actual, timeZone, Symbol.toPrimitive, undefined);
TemporalHelpers.observeProperty(actual, timeZone, "id", "Etc/Bogus");
TemporalHelpers.observeProperty(actual, timeZone, "toString", function () {
actual.push("call timeZone.toString");
return "Etc/TAI";
});

const result = timeZone.toJSON();
assert.sameValue(result, 'Etc/TAI', 'toString');
assert.compareArray(actual, expected);
assert.sameValue(result, "UTC", "toJSON gets the internal slot value");
assert.compareArray(actual, [], "should not invoke any observable operations");

This file was deleted.

This file was deleted.

0 comments on commit 87ed3b6

Please sign in to comment.