summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Temporal/Now/plainDateISO
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/Now/plainDateISO')
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/length.js28
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/prop-desc.js20
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/return-value.js15
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/shell.js0
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js18
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js21
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js18
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js27
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js64
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-leap-second.js21
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js23
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string.js38
-rw-r--r--js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js40
14 files changed, 333 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/browser.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/browser.js
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/length.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/length.js
new file mode 100644
index 0000000000..1f278d493c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/length.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2020 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.now.plaindateiso
+description: Temporal.Now.plainDateISO.length is 0
+info: |
+ Every built-in function object, including constructors, has a "length" property whose value is
+ an integer. Unless otherwise specified, this value is equal to the largest number of named
+ arguments shown in the subclause headings for the function description. Optional parameters
+ (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
+ «...name») are not included in the default argument count.
+
+ Unless otherwise specified, the "length" property of a built-in function object has the
+ attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+verifyProperty(Temporal.Now.plainDateISO, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/prop-desc.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/prop-desc.js
new file mode 100644
index 0000000000..ae966c8253
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/prop-desc.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: The "plainDateISO" property of Temporal.Now
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+assert.sameValue(typeof Temporal.Now.plainDateISO, "function", "typeof is function");
+
+verifyProperty(Temporal.Now, "plainDateISO", {
+ enumerable: false,
+ writable: true,
+ configurable: true
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/return-value.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/return-value.js
new file mode 100644
index 0000000000..1431597fcd
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/return-value.js
@@ -0,0 +1,15 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: Functions when time zone argument is omitted
+features: [Temporal]
+---*/
+
+const d = Temporal.Now.plainDateISO();
+assert(d instanceof Temporal.PlainDate);
+assert.sameValue(d.getISOFields().calendar, "iso8601", "calendar slot should store a string");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/shell.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/shell.js
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js
new file mode 100644
index 0000000000..637dc35eac
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds
+features: [Temporal]
+includes: [temporalHelpers.js]
+---*/
+
+[3600_000_000_000.5, NaN].forEach((wrongOffset) => {
+ const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
+
+ assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js
new file mode 100644
index 0000000000..93adafc9a1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable
+features: [BigInt, Symbol, Temporal, arrow-function]
+---*/
+
+[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => {
+ const timeZone = new Temporal.TimeZone("UTC");
+
+ timeZone.getOffsetNanosecondsFor = notCallable;
+ assert.throws(
+ TypeError,
+ () => Temporal.Now.plainDateISO(timeZone),
+ `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError`
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js
new file mode 100644
index 0000000000..eb0b46e888
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: RangeError thrown if time zone reports an offset that is out of range
+features: [Temporal]
+includes: [temporalHelpers.js]
+---*/
+
+[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => {
+ const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
+
+ assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js
new file mode 100644
index 0000000000..fde130990e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: TypeError thrown if time zone reports an offset that is not a Number
+features: [Temporal]
+includes: [temporalHelpers.js]
+---*/
+
+[
+ undefined,
+ null,
+ true,
+ "+01:00",
+ Symbol(),
+ 3600_000_000_000n,
+ {},
+ { valueOf() { return 3600_000_000_000; } },
+].forEach((wrongOffset) => {
+ const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset);
+
+ assert.throws(TypeError, () => Temporal.Now.plainDateISO(timeZone));
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js
new file mode 100644
index 0000000000..c3c67142b1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js
@@ -0,0 +1,64 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances
+features: [Temporal]
+---*/
+
+let timeZone = "2021-08-19T17:30";
+assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "bare date-time string is not a time zone");
+
+[
+ "2021-08-19T17:30-07:00:01",
+ "2021-08-19T17:30-07:00:00",
+ "2021-08-19T17:30-07:00:00.1",
+ "2021-08-19T17:30-07:00:00.0",
+ "2021-08-19T17:30-07:00:00.01",
+ "2021-08-19T17:30-07:00:00.00",
+ "2021-08-19T17:30-07:00:00.001",
+ "2021-08-19T17:30-07:00:00.000",
+ "2021-08-19T17:30-07:00:00.0001",
+ "2021-08-19T17:30-07:00:00.0000",
+ "2021-08-19T17:30-07:00:00.00001",
+ "2021-08-19T17:30-07:00:00.00000",
+ "2021-08-19T17:30-07:00:00.000001",
+ "2021-08-19T17:30-07:00:00.000000",
+ "2021-08-19T17:30-07:00:00.0000001",
+ "2021-08-19T17:30-07:00:00.0000000",
+ "2021-08-19T17:30-07:00:00.00000001",
+ "2021-08-19T17:30-07:00:00.00000000",
+ "2021-08-19T17:30-07:00:00.000000001",
+ "2021-08-19T17:30-07:00:00.000000000",
+].forEach((timeZone) => {
+ assert.throws(
+ RangeError,
+ () => Temporal.Now.plainDateISO(timeZone),
+ `ISO string ${timeZone} with a sub-minute offset is not a valid time zone`
+ );
+});
+
+// The following are all valid strings so should not throw:
+
+[
+ "2021-08-19T17:30Z",
+ "2021-08-19T1730Z",
+ "2021-08-19T17:30-07:00",
+ "2021-08-19T1730-07:00",
+ "2021-08-19T17:30-0700",
+ "2021-08-19T1730-0700",
+ "2021-08-19T17:30[UTC]",
+ "2021-08-19T1730[UTC]",
+ "2021-08-19T17:30Z[UTC]",
+ "2021-08-19T1730Z[UTC]",
+ "2021-08-19T17:30-07:00[UTC]",
+ "2021-08-19T1730-07:00[UTC]",
+ "2021-08-19T17:30-0700[UTC]",
+ "2021-08-19T1730-0700[UTC]",
+].forEach((timeZone) => {
+ Temporal.Now.plainDateISO(timeZone);
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-leap-second.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-leap-second.js
new file mode 100644
index 0000000000..fb2dbbee02
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-leap-second.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: Leap second is a valid ISO string for TimeZone
+features: [Temporal]
+---*/
+
+let timeZone = "2016-12-31T23:59:60+00:00[UTC]";
+
+// A string with a leap second is a valid ISO string, so the following
+// operation should not throw
+
+Temporal.Now.plainDateISO(timeZone);
+
+timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]";
+assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), "leap second in time zone name not valid");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js
new file mode 100644
index 0000000000..a3abf91147
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: Negative zero, as an extended year, is rejected
+features: [Temporal, arrow-function]
+---*/
+
+const invalidStrings = [
+ "-000000-10-31T17:45Z",
+ "-000000-10-31T17:45+00:00[UTC]",
+];
+invalidStrings.forEach((timeZone) => {
+ assert.throws(
+ RangeError,
+ () => Temporal.Now.plainDateISO(timeZone),
+ "reject minus zero as extended year"
+ );
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string.js
new file mode 100644
index 0000000000..eb02175a5e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-string.js
@@ -0,0 +1,38 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: Time zone IDs are valid input for a time zone
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor");
+Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up");
+ },
+});
+const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor");
+Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up");
+ },
+});
+
+// The following are all valid strings so should not throw:
+
+["UTC", "+01:00"].forEach((timeZone) => {
+ Temporal.Now.plainDateISO(timeZone);
+});
+
+Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal);
+Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js
new file mode 100644
index 0000000000..d4e5af5fb7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js
@@ -0,0 +1,40 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.now.plaindateiso
+description: >
+ Appropriate error thrown when argument cannot be converted to a valid string
+ or object for TimeZone
+features: [BigInt, Symbol, Temporal]
+---*/
+
+const primitiveTests = [
+ [null, "null"],
+ [true, "boolean"],
+ ["", "empty string"],
+ [1, "number that doesn't convert to a valid ISO string"],
+ [19761118, "number that would convert to a valid ISO string in other contexts"],
+ [1n, "bigint"],
+];
+
+for (const [timeZone, description] of primitiveTests) {
+ assert.throws(
+ typeof timeZone === 'string' ? RangeError : TypeError,
+ () => Temporal.Now.plainDateISO(timeZone),
+ `${description} does not convert to a valid ISO string`
+ );
+}
+
+const typeErrorTests = [
+ [Symbol(), "symbol"],
+ [{}, "object not implementing time zone protocol"],
+ [new Temporal.Calendar("iso8601"), "calendar instance"],
+];
+
+for (const [timeZone, description] of typeErrorTests) {
+ assert.throws(TypeError, () => Temporal.Now.plainDateISO(timeZone), `${description} is not a valid object and does not convert to a string`);
+}
+
+reportCompare(0, 0);