-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Add tests for calendarName: "critical" option
See tc39/proposal-temporal#2397 This normative change adds a new accepted value for the calendarName option in various toString() methods.
- Loading branch information
Showing
25 changed files
with
140 additions
and
15 deletions.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.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,24 @@ | ||
// 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.plaindate.prototype.tostring | ||
description: > | ||
If calendarName is "calendar", the calendar ID should be included and prefixed | ||
with "!". | ||
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"], | ||
]; | ||
|
||
for (const [args, expected, description] of tests) { | ||
const date = new Temporal.PlainDate(2000, 5, 2, ...args); | ||
const result = date.toString({ calendarName: "critical" }); | ||
assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.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,24 @@ | ||
// 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.plaindatetime.prototype.tostring | ||
description: > | ||
If calendarName is "calendar", the calendar ID should be included and prefixed | ||
with "!". | ||
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"], | ||
]; | ||
|
||
for (const [args, expected, description] of tests) { | ||
const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); | ||
const result = date.toString({ calendarName: "critical" }); | ||
assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.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,24 @@ | ||
// 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.plainmonthday.prototype.tostring | ||
description: > | ||
If calendarName is "calendar", the calendar ID should be included and prefixed | ||
with "!". | ||
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"], | ||
]; | ||
|
||
for (const [args, expected, description] of tests) { | ||
const monthday = new Temporal.PlainMonthDay(5, 2, ...args); | ||
const result = monthday.toString({ calendarName: "critical" }); | ||
assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.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,24 @@ | ||
// 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.plainyearmonth.prototype.tostring | ||
description: > | ||
If calendarName is "calendar", the calendar ID should be included and prefixed | ||
with "!". | ||
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"], | ||
]; | ||
|
||
for (const [args, expected, description] of tests) { | ||
const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); | ||
const result = yearmonth.toString({ calendarName: "critical" }); | ||
assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); | ||
} |
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
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.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,24 @@ | ||
// 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 calendarName is "calendar", the calendar ID should be included and prefixed | ||
with "!". | ||
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"], | ||
]; | ||
|
||
for (const [args, expected, description] of tests) { | ||
const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); | ||
const result = date.toString({ calendarName: "critical" }); | ||
assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); | ||
} |
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
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