forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Improve existing tests for ZDT#toString timeZoneName option
Based on the improvements just made to the calendarName option, improve the tests for the timeZoneName option of ZonedDateTime.prototype.toString as well.
- Loading branch information
Showing
5 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.zoneddatetime.prototype.tostring | ||
description: If timeZoneName is "auto", the time zone ID should be included. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["UTC", "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in UTC"], | ||
["+01:00", "1970-01-01T02:01:01.987654321+01:00[+01:00]", "built-in offset"], | ||
[{ | ||
getOffsetNanosecondsFor() { return 0; }, | ||
toString() { return "Etc/Custom"; }, | ||
}, "1970-01-01T01:01:01.987654321+00:00[Etc/Custom]", "custom"], | ||
]; | ||
|
||
for (const [timeZone, expected, description] of tests) { | ||
const date = new Temporal.ZonedDateTime(3661_987_654_321n, timeZone); | ||
const result = date.toString({ timeZoneName: "auto" }); | ||
assert.sameValue(result, expected, `${description} time zone for timeZoneName = auto`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (C) 2022 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.zoneddatetime.prototype.tostring | ||
description: If timeZoneName is "never", the time zone ID should be omitted. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
["UTC", "1970-01-01T01:01:01.987654321+00:00", "built-in UTC"], | ||
["+01:00", "1970-01-01T02:01:01.987654321+01:00", "built-in offset"], | ||
[{ | ||
getOffsetNanosecondsFor() { return 0; }, | ||
toString() { return "Etc/Custom"; }, | ||
}, "1970-01-01T01:01:01.987654321+00:00", "custom"], | ||
]; | ||
|
||
for (const [timeZone, expected, description] of tests) { | ||
const date = new Temporal.ZonedDateTime(3661_987_654_321n, timeZone); | ||
const result = date.toString({ timeZoneName: "never" }); | ||
assert.sameValue(result, expected, `${description} time zone for timeZoneName = never`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters