summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/Instant
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/intl402/Temporal/Instant
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/intl402/Temporal/Instant')
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined.js21
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js50
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-undefined.js21
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js22
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js31
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js31
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/browser.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/shell.js0
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js31
-rw-r--r--js/src/tests/test262/intl402/Temporal/Instant/shell.js0
19 files changed, 207 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/shell.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined.js
new file mode 100644
index 0000000000..6148d02e04
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/locales-undefined.js
@@ -0,0 +1,21 @@
+// |reftest| skip -- Temporal is not supported
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.instant.prototype.tolocalestring
+description: Omitting the locales argument defaults to the DateTimeFormat default
+features: [BigInt, Temporal]
+---*/
+
+const instant = new Temporal.Instant(957270896_987_650_000n);
+const defaultFormatter = new Intl.DateTimeFormat([], Object.create(null));
+const expected = defaultFormatter.format(instant);
+
+const actualExplicit = instant.toLocaleString(undefined);
+assert.sameValue(actualExplicit, expected, "default locale is determined by Intl.DateTimeFormat");
+
+const actualImplicit = instant.toLocaleString();
+assert.sameValue(actualImplicit, expected, "default locale is determined by Intl.DateTimeFormat");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js
new file mode 100644
index 0000000000..e79a627e54
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-conflict.js
@@ -0,0 +1,50 @@
+// |reftest| skip -- Temporal is not supported
+// Copyright (C) 2021 Kate Miháliková. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sup-temporal.instant.prototype.tolocalestring
+description: >
+ Conflicting properties of dateStyle must be rejected with a TypeError for the options argument
+info: |
+ Using sec-temporal-getdatetimeformatpattern:
+ GetDateTimeFormatPattern ( dateStyle, timeStyle, matcher, opt, dataLocaleData, hc )
+
+ 1. If dateStyle is not undefined or timeStyle is not undefined, then
+ a. For each row in Table 7, except the header row, do
+ i. Let prop be the name given in the Property column of the row.
+ ii. Let p be opt.[[<prop>]].
+ iii. If p is not undefined, then
+ 1. Throw a TypeError exception.
+features: [BigInt, Temporal]
+---*/
+
+// Table 14 - Supported fields + example value for each field
+const conflictingOptions = [
+ [ "weekday", "short" ],
+ [ "era", "short" ],
+ [ "year", "numeric" ],
+ [ "month", "numeric" ],
+ [ "day", "numeric" ],
+ [ "hour", "numeric" ],
+ [ "minute", "numeric" ],
+ [ "second", "numeric" ],
+ [ "dayPeriod", "short" ],
+ [ "fractionalSecondDigits", 3 ],
+];
+const instant = new Temporal.Instant(957270896_987_650_000n);
+
+assert.sameValue(typeof instant.toLocaleString("en", { dateStyle: "short" }), "string");
+assert.sameValue(typeof instant.toLocaleString("en", { timeStyle: "short" }), "string");
+
+for (const [ option, value ] of conflictingOptions) {
+ assert.throws(TypeError, function() {
+ instant.toLocaleString("en", { [option]: value, dateStyle: "short" });
+ }, `instant.toLocaleString("en", { ${option}: "${value}", dateStyle: "short" }) throws TypeError`);
+
+ assert.throws(TypeError, function() {
+ instant.toLocaleString("en", { [option]: value, timeStyle: "short" });
+ }, `instant.toLocaleString("en", { ${option}: "${value}", timeStyle: "short" }) throws TypeError`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-undefined.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-undefined.js
new file mode 100644
index 0000000000..2d5833d5ec
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/options-undefined.js
@@ -0,0 +1,21 @@
+// |reftest| skip -- Temporal is not supported
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.instant.prototype.tolocalestring
+description: Verify that undefined options are handled correctly.
+features: [BigInt, Temporal]
+---*/
+
+const instant = new Temporal.Instant(957270896_987_650_000n);
+const defaultFormatter = new Intl.DateTimeFormat('en', Object.create(null));
+const expected = defaultFormatter.format(instant);
+
+const actualExplicit = instant.toLocaleString('en', undefined);
+assert.sameValue(actualExplicit, expected, "default locale is determined by Intl.DateTimeFormat");
+
+const actualImplicit = instant.toLocaleString('en');
+assert.sameValue(actualImplicit, expected, "default locale is determined by Intl.DateTimeFormat");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/shell.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/shell.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js
new file mode 100644
index 0000000000..15cc0dfaca
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-offset.js
@@ -0,0 +1,22 @@
+// |reftest| skip -- Temporal is not supported
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.instant.prototype.tostring
+description: The time zone offset part of the string serialization (Intl time zones)
+features: [BigInt, Temporal]
+---*/
+
+const instant = new Temporal.Instant(0n);
+
+function test(timeZoneIdentifier, expected, description) {
+ const timeZone = new Temporal.TimeZone(timeZoneIdentifier);
+ assert.sameValue(instant.toString({ timeZone }), expected, description);
+}
+
+test("Europe/Berlin", "1970-01-01T01:00:00+01:00", "positive offset");
+test("America/New_York", "1969-12-31T19:00:00-05:00", "negative offset");
+test("Africa/Monrovia", "1969-12-31T23:15:30-00:45", "sub-minute offset");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js
new file mode 100644
index 0000000000..eb823f64c1
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toString/timezone-string-datetime.js
@@ -0,0 +1,31 @@
+// |reftest| skip -- Temporal is not supported
+// 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.instant.prototype.tostring
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with Intl time zones)
+features: [Temporal]
+---*/
+
+const instance = new Temporal.Instant(0n);
+
+let timeZone = "2021-08-19T17:30[America/Vancouver]";
+const result1 = instance.toString({ timeZone });
+assert.sameValue(result1.substr(-6), "-08:00", "date-time + IANA annotation is the IANA time zone");
+const result2 = instance.toString({ timeZone: { timeZone } });
+assert.sameValue(result2.substr(-6), "-08:00", "date-time + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30Z[America/Vancouver]";
+const result3 = instance.toString({ timeZone });
+assert.sameValue(result3.substr(-6), "-08:00", "date-time + Z + IANA annotation is the IANA time zone");
+const result4 = instance.toString({ timeZone: { timeZone } });
+assert.sameValue(result4.substr(-6), "-08:00", "date-time + Z + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30-07:00[America/Vancouver]";
+const result5 = instance.toString({ timeZone });
+assert.sameValue(result5.substr(-6), "-08:00", "date-time + offset + IANA annotation is the IANA time zone");
+const result6 = instance.toString({ timeZone: { timeZone } });
+assert.sameValue(result6.substr(-6), "-08:00", "date-time + offset + IANA annotation is the IANA time zone (string in property bag)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/shell.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js
new file mode 100644
index 0000000000..96d1a11e92
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js
@@ -0,0 +1,31 @@
+// |reftest| skip -- Temporal is not supported
+// 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.instant.prototype.tozoneddatetime
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with Intl time zones)
+features: [Temporal]
+---*/
+
+const instance = new Temporal.Instant(0n);
+
+let timeZone = "2021-08-19T17:30[America/Vancouver]";
+const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" });
+assert.sameValue(result1.timeZone.id, "America/Vancouver", "date-time + IANA annotation is the IANA time zone");
+const result2 = instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" });
+assert.sameValue(result2.timeZone.id, "America/Vancouver", "date-time + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30Z[America/Vancouver]";
+const result3 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" });
+assert.sameValue(result3.timeZone.id, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone");
+const result4 = instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" });
+assert.sameValue(result4.timeZone.id, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30-07:00[America/Vancouver]";
+const result5 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" });
+assert.sameValue(result5.timeZone.id, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone");
+const result6 = instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" });
+assert.sameValue(result6.timeZone.id, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone (string in property bag)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/browser.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/browser.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/shell.js
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js
new file mode 100644
index 0000000000..5278f1db4e
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js
@@ -0,0 +1,31 @@
+// |reftest| skip -- Temporal is not supported
+// 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.instant.prototype.tozoneddatetimeiso
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with Intl time zones)
+features: [Temporal]
+---*/
+
+const instance = new Temporal.Instant(0n);
+
+let timeZone = "2021-08-19T17:30[America/Vancouver]";
+const result1 = instance.toZonedDateTimeISO(timeZone);
+assert.sameValue(result1.timeZone.id, "America/Vancouver", "date-time + IANA annotation is the IANA time zone");
+const result2 = instance.toZonedDateTimeISO({ timeZone });
+assert.sameValue(result2.timeZone.id, "America/Vancouver", "date-time + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30Z[America/Vancouver]";
+const result3 = instance.toZonedDateTimeISO(timeZone);
+assert.sameValue(result3.timeZone.id, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone");
+const result4 = instance.toZonedDateTimeISO({ timeZone });
+assert.sameValue(result4.timeZone.id, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone (string in property bag)");
+
+timeZone = "2021-08-19T17:30-07:00[America/Vancouver]";
+const result5 = instance.toZonedDateTimeISO(timeZone);
+assert.sameValue(result5.timeZone.id, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone");
+const result6 = instance.toZonedDateTimeISO({ timeZone });
+assert.sameValue(result6.timeZone.id, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone (string in property bag)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/intl402/Temporal/Instant/shell.js b/js/src/tests/test262/intl402/Temporal/Instant/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/Instant/shell.js