Diff
Modified: trunk/JSTests/ChangeLog (283665 => 283666)
--- trunk/JSTests/ChangeLog 2021-10-06 21:24:39 UTC (rev 283665)
+++ trunk/JSTests/ChangeLog 2021-10-06 21:38:11 UTC (rev 283666)
@@ -3,8 +3,19 @@
[JSC] Update test262
https://bugs.webkit.org/show_bug.cgi?id=231201
+ Add tests that were somehow cut off in the previous patch.
+
Reviewed by Ross Kirsling.
+ * test262/test/built-ins/Temporal/Now/*: Added.
+
+2021-10-06 Philip Chimento <[email protected]>
+
+ [JSC] Update test262
+ https://bugs.webkit.org/show_bug.cgi?id=231201
+
+ Reviewed by Ross Kirsling.
+
Update test262 to latest, to bring in Temporal tests.
* test262/config.yaml: Ignore tests that depend on unimplemented parts
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,22 @@
+// 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.plaindate
+description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
+info: |
+ sec-temporal.now.plaindate step 1:
+ 1. Let _dateTime_ be ? SystemDateTime(_temporalTimeZoneLike_, _calendar_).
+ sec-temporal-systemdatetime step 3:
+ 3. Let _calendar_ be ? ToTemporalCalendar(_calendarLike_).
+ sec-temporal-totemporalcalendar step 1.a:
+ a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
+ i. Return _temporalCalendarLike_.[[Calendar]].
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => {
+ const result = Temporal.Now.plainDate(temporalObject);
+ assert.sameValue(result.calendar, calendar, "Temporal object coerced to calendar");
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/length.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/length.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/length.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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.plaindate
+description: Temporal.Now.plainDate.length is 1
+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.plainDate, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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.plaindate
+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.plainDate("iso8601", timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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.plaindate
+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.plainDate("iso8601", timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,24 @@
+// 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.plaindate
+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.plainDate("iso8601", timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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.plaindate
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances
+features: [Temporal]
+---*/
+
+let timeZone = "2021-08-19T17:30";
+assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "bare date-time string is not a time zone");
+assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", { timeZone }), "bare date-time string is not a time zone");
+
+// The following are all valid strings so should not throw:
+
+[
+ "2021-08-19T17:30Z",
+ "2021-08-19T17:30-07:00",
+ "2021-08-19T17:30[America/Vancouver]",
+ "2021-08-19T17:30Z[America/Vancouver]",
+ "2021-08-19T17:30-07:00[America/Vancouver]",
+].forEach((timeZone) => {
+ Temporal.Now.plainDate("iso8601", timeZone);
+ Temporal.Now.plainDate("iso8601", { timeZone });
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,48 @@
+// 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.plaindate
+description: PlainDateTime.toPlainDate is not observably called
+includes: [compareArray.js]
+features: [Temporal]
+---*/
+
+const actual = [];
+const expected = [
+ "has timeZone.timeZone",
+ "get timeZone.getOffsetNanosecondsFor",
+ "call timeZone.getOffsetNanosecondsFor",
+];
+
+Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainDate", {
+ get() {
+ actual.push("get Temporal.PlainDateTime.prototype.toPlainDate");
+ return function() {
+ actual.push("call Temporal.PlainDateTime.prototype.toPlainDate");
+ };
+ },
+});
+
+const timeZone = new Proxy({
+ getOffsetNanosecondsFor(instant) {
+ actual.push("call timeZone.getOffsetNanosecondsFor");
+ assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
+ return 86399_999_999_999;
+ },
+}, {
+ has(target, property) {
+ actual.push(`has timeZone.${property}`);
+ return property in target;
+ },
+ get(target, property) {
+ actual.push(`get timeZone.${property}`);
+ return target[property];
+ },
+});
+
+const result = Temporal.Now.plainDate("iso8601", timeZone);
+assert.notSameValue(result, undefined);
+assert.sameValue(result instanceof Temporal.PlainDate, true);
+
+assert.compareArray(actual, expected);
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/length.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/length.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/length.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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,
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,24 @@
+// 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));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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");
+assert.throws(RangeError, () => Temporal.Now.plainDateISO({ timeZone }), "bare date-time string is not a time zone");
+
+// The following are all valid strings so should not throw:
+
+[
+ "2021-08-19T17:30Z",
+ "2021-08-19T17:30-07:00",
+ "2021-08-19T17:30[America/Vancouver]",
+ "2021-08-19T17:30Z[America/Vancouver]",
+ "2021-08-19T17:30-07:00[America/Vancouver]",
+].forEach((timeZone) => {
+ Temporal.Now.plainDateISO(timeZone);
+ Temporal.Now.plainDateISO({ timeZone });
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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.plaindatetime
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances
+features: [Temporal]
+---*/
+
+let timeZone = "2021-08-19T17:30";
+assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), "bare date-time string is not a time zone");
+assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", { timeZone }), "bare date-time string is not a time zone");
+
+// The following are all valid strings so should not throw:
+
+[
+ "2021-08-19T17:30Z",
+ "2021-08-19T17:30-07:00",
+ "2021-08-19T17:30[America/Vancouver]",
+ "2021-08-19T17:30Z[America/Vancouver]",
+ "2021-08-19T17:30-07:00[America/Vancouver]",
+].forEach((timeZone) => {
+ Temporal.Now.plainDateTime("iso8601", timeZone);
+ Temporal.Now.plainDateTime("iso8601", { timeZone });
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainDateTime/timezone.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,42 @@
+// 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.plaindatetime
+description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result
+includes: [compareArray.js]
+features: [Temporal]
+---*/
+
+const actual = [];
+const expected = [
+ "has timeZone.timeZone",
+ "get timeZone.getOffsetNanosecondsFor",
+ "call timeZone.getOffsetNanosecondsFor",
+];
+
+const timeZone = new Proxy({
+ getOffsetNanosecondsFor(instant) {
+ actual.push("call timeZone.getOffsetNanosecondsFor");
+ assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
+ return -Number(instant.epochNanoseconds % 86400_000_000_000n);
+ },
+}, {
+ has(target, property) {
+ actual.push(`has timeZone.${property}`);
+ return property in target;
+ },
+ get(target, property) {
+ actual.push(`get timeZone.${property}`);
+ return target[property];
+ },
+});
+
+const calendar = Temporal.Calendar.from("iso8601");
+
+const result = Temporal.Now.plainDateTime(calendar, timeZone);
+for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) {
+ assert.sameValue(result[property], 0, property);
+}
+
+assert.compareArray(actual, expected);
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/length.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/length.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/length.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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.plaintimeiso
+description: Temporal.Now.plainTimeISO.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.plainTimeISO, "length", {
+ value: 0,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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.plaintimeiso
+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.plainTimeISO(timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,15 @@
+// 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.plaintimeiso
+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.plainTimeISO(timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,24 @@
+// 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.plaintimeiso
+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.plainTimeISO(timeZone));
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,25 @@
+// 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.plaintimeiso
+description: Conversion of ISO date-time strings to Temporal.TimeZone instances
+features: [Temporal]
+---*/
+
+let timeZone = "2021-08-19T17:30";
+assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone), "bare date-time string is not a time zone");
+assert.throws(RangeError, () => Temporal.Now.plainTimeISO({ timeZone }), "bare date-time string is not a time zone");
+
+// The following are all valid strings so should not throw:
+
+[
+ "2021-08-19T17:30Z",
+ "2021-08-19T17:30-07:00",
+ "2021-08-19T17:30[America/Vancouver]",
+ "2021-08-19T17:30Z[America/Vancouver]",
+ "2021-08-19T17:30-07:00[America/Vancouver]",
+].forEach((timeZone) => {
+ Temporal.Now.plainTimeISO(timeZone);
+ Temporal.Now.plainTimeISO({ timeZone });
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/timezone.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,41 @@
+// 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.plaintimeiso
+description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result
+includes: [compareArray.js]
+features: [Temporal]
+---*/
+
+const actual = [];
+const expected = [
+ "has timeZone.timeZone",
+ "get timeZone.getOffsetNanosecondsFor",
+ "call timeZone.getOffsetNanosecondsFor",
+];
+
+const timeZone = new Proxy({
+ getOffsetNanosecondsFor(instant) {
+ actual.push("call timeZone.getOffsetNanosecondsFor");
+ assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
+ return -Number(instant.epochNanoseconds % 86400_000_000_000n);
+ },
+}, {
+ has(target, property) {
+ actual.push(`has timeZone.${property}`);
+ return property in target;
+ },
+ get(target, property) {
+ actual.push(`get timeZone.${property}`);
+ return target[property];
+ },
+});
+
+const result = Temporal.Now.plainTimeISO(timeZone);
+assert.sameValue(result instanceof Temporal.PlainTime, true);
+for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) {
+ assert.sameValue(result[property], 0, property);
+}
+
+assert.compareArray(actual, expected);
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,50 @@
+// 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.plaintimeiso
+description: PlainDateTime.toPlainTime is not observably called
+includes: [compareArray.js]
+features: [Temporal]
+---*/
+
+const actual = [];
+const expected = [
+ "has timeZone.timeZone",
+ "get timeZone.getOffsetNanosecondsFor",
+ "call timeZone.getOffsetNanosecondsFor",
+];
+
+Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainTime", {
+ get() {
+ actual.push("get Temporal.PlainDateTime.prototype.toPlainTime");
+ return function() {
+ actual.push("call Temporal.PlainDateTime.prototype.toPlainTime");
+ };
+ },
+});
+
+const timeZone = new Proxy({
+ getOffsetNanosecondsFor(instant) {
+ actual.push("call timeZone.getOffsetNanosecondsFor");
+ assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
+ return -Number(instant.epochNanoseconds % 86400_000_000_000n);
+ },
+}, {
+ has(target, property) {
+ actual.push(`has timeZone.${property}`);
+ return property in target;
+ },
+ get(target, property) {
+ actual.push(`get timeZone.${property}`);
+ return target[property];
+ },
+});
+
+const result = Temporal.Now.plainTimeISO(timeZone);
+assert.sameValue(result instanceof Temporal.PlainTime, true);
+for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) {
+ assert.sameValue(result[property], 0, property);
+}
+
+assert.compareArray(actual, expected);
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/prop-desc.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/prop-desc.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/prop-desc.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,16 @@
+// 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-@@tostringtag
+description: The @@toStringTag property of Temporal.Now
+includes: [propertyHelper.js]
+features: [Symbol.toStringTag, Temporal]
+---*/
+
+verifyProperty(Temporal.Now, Symbol.toStringTag, {
+ value: "Temporal.Now",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
Added: trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/string.js (0 => 283666)
--- trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/string.js (rev 0)
+++ trunk/JSTests/test262/test/built-ins/Temporal/Now/toStringTag/string.js 2021-10-06 21:38:11 UTC (rev 283666)
@@ -0,0 +1,10 @@
+// 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-@@tostringtag
+description: The @@toStringTag property of Temporal.Now produces the correct value in toString
+features: [Symbol.toStringTag, Temporal]
+---*/
+
+assert.sameValue(String(Temporal.Now), "[object Temporal.Now]");