From 3b6040b2139f94fef77f72b6e3448d963082c9f1 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 11:39:28 -0700 Subject: [PATCH 01/11] Temporal: Adjust relativeto-string-datetime tests As of https://github.com/tc39/proposal-temporal/pull/2397 which reached consensus in the August 2022 TC39 meeting, a date-time + Z with no bracket annotation is no longer accepted as a relativeTo parameter; either the Z should be removed or a bracket annotation should be added. This requires adjusting a few existing tests, but doesn't require any new ones. --- .../add/relativeto-string-datetime.js | 22 +++++++++---------- .../round/relativeto-string-datetime.js | 22 +++++++++---------- .../subtract/relativeto-string-datetime.js | 22 +++++++++---------- .../total/relativeto-string-datetime.js | 22 +++++++++---------- 4 files changed, 40 insertions(+), 48 deletions(-) diff --git a/test/built-ins/Temporal/Duration/prototype/add/relativeto-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/add/relativeto-string-datetime.js index 2f27346f3f5..2172efa6743 100644 --- a/test/built-ins/Temporal/Duration/prototype/add/relativeto-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/add/relativeto-string-datetime.js @@ -16,25 +16,23 @@ let relativeTo = "2019-11-01T00:00"; const result1 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bare date-time string is a plain relativeTo"); -relativeTo = "2019-11-01T00:00Z"; -const result2 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z is a plain relativeTo"); - relativeTo = "2019-11-01T00:00-07:00"; -const result3 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); +const result2 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); +TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); relativeTo = "2019-11-01T00:00[-07:00]"; -const result4 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); +const result3 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); +TemporalHelpers.assertDuration(result3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00Z[-07:00]"; -const result5 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); +const result4 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); +TemporalHelpers.assertDuration(result4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00+00:00[UTC]"; -const result6 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); -TemporalHelpers.assertDuration(result6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +const result5 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); +TemporalHelpers.assertDuration(result5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +relativeTo = "2019-11-01T00:00Z"; +assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "date-time + Z throws without an IANA annotation"); relativeTo = "2019-11-01T00:00+04:15[UTC]"; assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), "date-time + offset + IANA annotation throws if wall time and exact time mismatch"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-string-datetime.js index 2585f935794..4993ad1e577 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-string-datetime.js @@ -16,25 +16,23 @@ let relativeTo = "2019-11-01T00:00"; const result1 = instance.round({ largestUnit: "years", relativeTo }); TemporalHelpers.assertDuration(result1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "bare date-time string is a plain relativeTo"); -relativeTo = "2019-11-01T00:00Z"; -const result2 = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + Z is a plain relativeTo"); - relativeTo = "2019-11-01T00:00-07:00"; -const result3 = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result3, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); +const result2 = instance.round({ largestUnit: "years", relativeTo }); +TemporalHelpers.assertDuration(result2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); relativeTo = "2019-11-01T00:00[-07:00]"; -const result4 = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); +const result3 = instance.round({ largestUnit: "years", relativeTo }); +TemporalHelpers.assertDuration(result3, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00Z[-07:00]"; -const result5 = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result5, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); +const result4 = instance.round({ largestUnit: "years", relativeTo }); +TemporalHelpers.assertDuration(result4, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00+00:00[UTC]"; -const result6 = instance.round({ largestUnit: "years", relativeTo }); -TemporalHelpers.assertDuration(result6, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +const result5 = instance.round({ largestUnit: "years", relativeTo }); +TemporalHelpers.assertDuration(result5, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +relativeTo = "2019-11-01T00:00Z"; +assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "date-time + Z throws without an IANA annotation"); relativeTo = "2019-11-01T00:00+04:15[UTC]"; assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "date-time + offset + IANA annotation throws if wall time and exact time mismatch"); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-string-datetime.js index 5c21f75693d..e31b31722ca 100644 --- a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-string-datetime.js @@ -16,25 +16,23 @@ let relativeTo = "2019-11-01T00:00"; const result1 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bare date-time string is a plain relativeTo"); -relativeTo = "2019-11-01T00:00Z"; -const result2 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z is a plain relativeTo"); - relativeTo = "2019-11-01T00:00-07:00"; -const result3 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); +const result2 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); +TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset is a plain relativeTo"); relativeTo = "2019-11-01T00:00[-07:00]"; -const result4 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); +const result3 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); +TemporalHelpers.assertDuration(result3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00Z[-07:00]"; -const result5 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); +const result4 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); +TemporalHelpers.assertDuration(result4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00+00:00[UTC]"; -const result6 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); -TemporalHelpers.assertDuration(result6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +const result5 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); +TemporalHelpers.assertDuration(result5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation is a zoned relativeTo"); +relativeTo = "2019-11-01T00:00Z"; +assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "date-time + Z throws without an IANA annotation"); relativeTo = "2019-11-01T00:00+04:15[UTC]"; assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), "date-time + offset + IANA annotation throws if wall time and exact time mismatch"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-string-datetime.js index d5160ba02d5..7ab80294cc7 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-string-datetime.js @@ -15,25 +15,23 @@ let relativeTo = "2019-11-01T00:00"; const result1 = instance.total({ unit: "days", relativeTo }); assert.sameValue(result1, 367, "bare date-time string is a plain relativeTo"); -relativeTo = "2019-11-01T00:00Z"; -const result2 = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result2, 367, "date-time + Z is a plain relativeTo"); - relativeTo = "2019-11-01T00:00-07:00"; -const result3 = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result3, 367, "date-time + offset is a plain relativeTo"); +const result2 = instance.total({ unit: "days", relativeTo }); +assert.sameValue(result2, 367, "date-time + offset is a plain relativeTo"); relativeTo = "2019-11-01T00:00[-07:00]"; -const result4 = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result4, 367, "date-time + IANA annotation is a zoned relativeTo"); +const result3 = instance.total({ unit: "days", relativeTo }); +assert.sameValue(result3, 367, "date-time + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00Z[-07:00]"; -const result5 = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result5, 367, "date-time + Z + IANA annotation is a zoned relativeTo"); +const result4 = instance.total({ unit: "days", relativeTo }); +assert.sameValue(result4, 367, "date-time + Z + IANA annotation is a zoned relativeTo"); relativeTo = "2019-11-01T00:00+00:00[UTC]"; -const result6 = instance.total({ unit: "days", relativeTo }); -assert.sameValue(result6, 367, "date-time + offset + IANA annotation is a zoned relativeTo"); +const result5 = instance.total({ unit: "days", relativeTo }); +assert.sameValue(result5, 367, "date-time + offset + IANA annotation is a zoned relativeTo"); +relativeTo = "2019-11-01T00:00Z"; +assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "date-time + Z throws without an IANA annotation"); relativeTo = "2019-11-01T00:00+04:15[UTC]"; assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "date-time + offset + IANA annotation throws if wall time and exact time mismatch"); From 5fe72b7a1095fae5d9f6c8fc4d833ffabfe6e9ed Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 12:42:48 -0700 Subject: [PATCH 02/11] Temporal: Add tests for time zone annotation with critical flag See https://github.com/tc39/proposal-temporal/pull/2397 Adds tests for ISO strings with named and numeric offset time zone annotations, with and without the critical flag, with various combinations of Z and offset in front of the annotation. --- .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 29 +++++++++++ .../argument-string-time-zone-annotation.js | 29 +++++++++++ .../Temporal/Instant/from/argument-string.js | 3 -- .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 37 ++++++++++++++ .../argument-string-time-zone-annotation.js | 38 +++++++++++++++ .../PlainDate/from/argument-string.js | 1 - .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 48 +++++++++++++++++++ .../argument-string-time-zone-annotation.js | 47 ++++++++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 29 +++++++++++ .../argument-string-time-zone-annotation.js | 30 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 48 +++++++++++++++++++ .../argument-string-time-zone-annotation.js | 30 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 45 +++++++++++++++++ .../argument-string-time-zone-annotation.js | 46 ++++++++++++++++++ .../argument-string-time-zone-annotation.js | 47 ++++++++++++++++++ .../argument-string-time-zone-annotation.js | 48 +++++++++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 48 +++++++++++++++++++ .../argument-string-time-zone-annotation.js | 29 +++++++++++ .../argument-string-time-zone-annotation.js | 30 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 32 +++++++++++++ .../argument-string-time-zone-annotation.js | 31 ++++++++++++ .../argument-string-time-zone-annotation.js | 33 +++++++++++++ .../argument-string-time-zone-annotation.js | 33 +++++++++++++ .../argument-string-time-zone-annotation.js | 35 ++++++++++++++ .../argument-string-time-zone-annotation.js | 37 ++++++++++++++ .../argument-string-time-zone-annotation.js | 37 ++++++++++++++ .../argument-string-time-zone-annotation.js | 40 ++++++++++++++++ .../argument-string-time-zone-annotation.js | 48 +++++++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ .../argument-string-time-zone-annotation.js | 39 +++++++++++++++ 65 files changed, 2320 insertions(+), 4 deletions(-) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Instant/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Instant/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..c4f942d1470 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.calendar.prototype.dateadd +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateAdd(arg, new Temporal.Duration()); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..d64c8c5164b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.calendar.prototype.dateuntil +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateUntil(arg, arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..82bb780b27b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.day +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.day(arg); + + assert.sameValue( + result, + 2, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..e7e14714631 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.dayofweek +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfWeek(arg); + + assert.sameValue( + result, + 2, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..b176931cdf9 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.dayofyear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfYear(arg); + + assert.sameValue( + result, + 123, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..71fb85359f8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.daysinmonth +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInMonth(arg); + + assert.sameValue( + result, + 31, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..8c39859f32a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.daysinweek +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInWeek(arg); + + assert.sameValue( + result, + 7, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..064d1fe3e6e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.daysinyear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInYear(arg); + + assert.sameValue( + result, + 366, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..3a2844bc081 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.inleapyear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.inLeapYear(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..dc31a960c5b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.month +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.month(arg); + + assert.sameValue( + result, + 5, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..2ad914e3ee6 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.monthcode +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthCode(arg); + + assert.sameValue( + result, + "M05", + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..0e13e59894a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.monthsinyear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthsInYear(arg); + + assert.sameValue( + result, + 12, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..9870ce77f8b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.weekofyear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.weekOfYear(arg); + + assert.sameValue( + result, + 18, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..c6eec6f3f12 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.year +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.year(arg); + + assert.sameValue( + result, + 2000, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Instant/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..c7b83c10e01 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Instant/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..15ef3ac5228 --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/argument-string-time-zone-annotation.js @@ -0,0 +1,29 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.from(arg); + + assert.sameValue( + result.epochNanoseconds, + 0n, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string.js b/test/built-ins/Temporal/Instant/from/argument-string.js index be1af8ee42c..bfea63e3aab 100644 --- a/test/built-ins/Temporal/Instant/from/argument-string.js +++ b/test/built-ins/Temporal/Instant/from/argument-string.js @@ -38,12 +38,9 @@ const tests = [ ['1976-11-18T15Z', 217177200000000000n], ['1976-11-18T15:23:30.123456789Z[u-ca=discord]', 217178610123456789n], ['1976-11-18T15:23:30.123456789Z[+00]', 217178610123456789n], - ['1976-11-18T15:23:30.123456789Z[+00:00]', 217178610123456789n], ['1976-11-18T15:23:30.123456789Z[-00]', 217178610123456789n], ['1976-11-18T15:23:30.123456789Z[-00:00]', 217178610123456789n], ['1976-11-18T15:23:30.123456789Z[+12]', 217178610123456789n], - ['1976-11-18T15:23:30.123456789Z[UTC]', 217178610123456789n], - ['1976-11-18T15:23:30.123456789Z[Europe/Paris]', 217178610123456789n], ['1976-11-18T15:23:30.123456789Z[NotATimeZone]', 217178610123456789n], ]; diff --git a/test/built-ins/Temporal/Instant/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..cdeeadc4664 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Instant/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..4e9721ad2ac --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Instant/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..0a45dad4503 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..68655e917c8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,37 @@ +// 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.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..d07fc87fbb2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-string-time-zone-annotation.js @@ -0,0 +1,38 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.from(arg); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string.js b/test/built-ins/Temporal/PlainDate/from/argument-string.js index 5a4c957beb0..81458306375 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-string.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-string.js @@ -31,7 +31,6 @@ const tests = [ ["+0019761118T15:23:30.1+0000", 1976, 11, "M11", 18], ["+0019761118T152330.1+00:00", 1976, 11, "M11", 18], ["+0019761118T152330.1+0000", 1976, 11, "M11", 18], - ["2020-01-01[Asia/Kolkata]", 2020, 1, "M01", 1], ]; for (const [input, ...expected] of tests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..0c92c35344f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..6cf4dc58d01 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..c709648fc57 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-time-zone-annotation.js @@ -0,0 +1,48 @@ +// 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.toplaindatetime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..2ed5bf5dc8a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-time-zone-annotation.js @@ -0,0 +1,47 @@ +// 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.tozoneddatetime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..f0ef737a5f6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..6e147813954 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..8da3e501259 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-string-time-zone-annotation.js @@ -0,0 +1,30 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.from(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 15, 23, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..385adc80618 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..81e53bc8d86 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..70aa8e3ddf6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..946197e5c99 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.withplaindate +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..3979231e8ce --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js @@ -0,0 +1,48 @@ +// 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.withplaintime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..e8b0b1fc8fe --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-time-zone-annotation.js @@ -0,0 +1,30 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-05-02T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-05-02T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-05-02T15:23[+00:00]", "numeric, with no offset"], + ["1976-05-02T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-05-02T15:23+00:00[UTC]", "named, with offset"], + ["1976-05-02T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainMonthDay.from(arg); + + TemporalHelpers.assertPlainMonthDay( + result, + "M05", 2, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..0d817fcb6cf --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-05-02T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-05-02T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-05-02T15:23[+00:00]", "numeric, with no offset"], + ["1976-05-02T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-05-02T15:23+00:00[UTC]", "named, with offset"], + ["1976-05-02T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainMonthDay(5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..5ae8e5af6bb --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,45 @@ +// 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.plaintime.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..6c85c8fc440 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-time-zone-annotation.js @@ -0,0 +1,46 @@ +// 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.plaintime.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.from(arg); + + TemporalHelpers.assertPlainTime( + result, + 12, 34, 56, 987, 654, 321, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..8d592c8a61a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,47 @@ +// 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.plaintime.prototype.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..61438712e90 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,48 @@ +// 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.plaintime.prototype.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..3afdf3b1f27 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.plaintime.prototype.toplaindatetime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..197bb338013 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.plaintime.prototype.tozoneddatetime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..7a0cba67126 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,48 @@ +// 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.plaintime.prototype.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..b39c057671a --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"], + ["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["2019-12-15T15:23[+00:00]", "numeric, with no offset"], + ["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"], + ["2019-12-15T15:23+00:00[UTC]", "named, with offset"], + ["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"], + ["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..57f9f0d8df0 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-time-zone-annotation.js @@ -0,0 +1,30 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"], + ["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["2019-12-15T15:23[+00:00]", "numeric, with no offset"], + ["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"], + ["2019-12-15T15:23+00:00[UTC]", "named, with offset"], + ["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"], + ["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.from(arg); + + TemporalHelpers.assertPlainYearMonth( + result, + 2019, 12, "M12", + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..639fa596c3f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"], + ["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["2019-12-15T15:23[+00:00]", "numeric, with no offset"], + ["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"], + ["2019-12-15T15:23+00:00[UTC]", "named, with offset"], + ["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"], + ["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..3f9e3273b51 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"], + ["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["2019-12-15T15:23[+00:00]", "numeric, with no offset"], + ["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"], + ["2019-12-15T15:23+00:00[UTC]", "named, with offset"], + ["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"], + ["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..8fed00f2167 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[Asia/Kolkata]", "named, with no offset"], + ["2019-12-15T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["2019-12-15T15:23[+00:00]", "numeric, with no offset"], + ["2019-12-15T15:23[!-02:30]", "numeric, with ! and no offset"], + ["2019-12-15T15:23+00:00[UTC]", "named, with offset"], + ["2019-12-15T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["2019-12-15T15:23+00:00[+01:00]", "numeric, with offset"], + ["2019-12-15T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..a6746a03cc2 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getinstantfor +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getInstantFor(arg); + + assert.sameValue( + result.epochNanoseconds, + 217_178_580_000_000_000n, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..c31d25dee38 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getnexttransition +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getNextTransition(arg); + + assert.sameValue( + result, + null, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..8f8d4a7d040 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getoffsetnanosecondsfor +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetNanosecondsFor(arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..ce875963970 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getoffsetstringfor +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetStringFor(arg); + + assert.sameValue( + result, + "+00:00", + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..ec4feff5a31 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.timezone.prototype.getplaindatetimefor +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPlainDateTimeFor(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..9cdd241e77a --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js @@ -0,0 +1,32 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [compareArray.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], + ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], + ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], + ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], + ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], + ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], + ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPossibleInstantsFor(arg); + + assert.compareArray( + result.map(i => i.epochNanoseconds), + [217_178_580_000_000_000n], + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..d85e05a2018 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getprevioustransition +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], + ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPreviousTransition(arg); + + assert.sameValue( + result, + null, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..327f7962af3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-time-zone-annotation.js @@ -0,0 +1,33 @@ +// 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.compare +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC]", "named, with no offset"], + ["1970-01-01T00:00[!UTC]", "named, with ! and no offset"], + ["1970-01-01T00:00[+00:00]", "numeric, with no offset"], + ["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"], + ["1970-01-01T00:00Z[UTC]", "named, with Z"], + ["1970-01-01T00:00Z[!UTC]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.ZonedDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..22f081061e9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-time-zone-annotation.js @@ -0,0 +1,33 @@ +// 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.from +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC]", "UTC", "named, with no offset"], + ["1970-01-01T00:00[!UTC]", "UTC", "named, with ! and no offset"], + ["1970-01-01T00:00[+00:00]", "+00:00", "numeric, with no offset"], + ["1970-01-01T00:00[!+00:00]", "+00:00", "numeric, with ! and no offset"], + ["1970-01-01T00:00Z[UTC]", "UTC", "named, with Z"], + ["1970-01-01T00:00Z[!UTC]", "UTC", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "+00:00", "numeric, with Z"], + ["1970-01-01T00:00Z[!+00:00]", "+00:00", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "UTC", "named, with offset"], + ["1970-01-01T00:00+00:00[!UTC]", "UTC", "named, with offset and !"], + ["1970-01-01T00:00+00:00[+00:00]", "+00:00", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+00:00]", "+00:00", "numeric, with offset and !"], +]; + +tests.forEach(([arg, expectedZone, description]) => { + const result = Temporal.ZonedDateTime.from(arg); + + assert.sameValue( + result.timeZone.toString(), + expectedZone, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..3de8846476c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js @@ -0,0 +1,35 @@ +// 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.equals +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC]", "UTC", "named, with no offset"], + ["1970-01-01T00:00[!UTC]", "UTC", "named, with ! and no offset"], + ["1970-01-01T00:00[+00:00]", "+00:00", "numeric, with no offset"], + ["1970-01-01T00:00[!+00:00]", "+00:00", "numeric, with ! and no offset"], + ["1970-01-01T00:00Z[UTC]", "UTC", "named, with Z"], + ["1970-01-01T00:00Z[!UTC]", "UTC", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "+00:00", "numeric, with Z"], + ["1970-01-01T00:00Z[!+00:00]", "+00:00", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "UTC", "named, with offset"], + ["1970-01-01T00:00+00:00[!UTC]", "UTC", "named, with offset and !"], + ["1970-01-01T00:00+00:00[+00:00]", "+00:00", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+00:00]", "+00:00", "numeric, with offset and !"], +]; + +tests.forEach(([arg, expectedZone, description]) => { + const timeZone = new Temporal.TimeZone(expectedZone); + const instance = new Temporal.ZonedDateTime(0n, timeZone); + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..cdf5de9ff5a --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js @@ -0,0 +1,37 @@ +// 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.since +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC]", "named, with no offset"], + ["1970-01-01T00:00[!UTC]", "named, with ! and no offset"], + ["1970-01-01T00:00[+00:00]", "numeric, with no offset"], + ["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"], + ["1970-01-01T00:00Z[UTC]", "named, with Z"], + ["1970-01-01T00:00Z[!UTC]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..37ed65f3094 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js @@ -0,0 +1,37 @@ +// 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.until +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC]", "named, with no offset"], + ["1970-01-01T00:00[!UTC]", "named, with ! and no offset"], + ["1970-01-01T00:00[+00:00]", "numeric, with no offset"], + ["1970-01-01T00:00[!+00:00]", "numeric, with ! and no offset"], + ["1970-01-01T00:00Z[UTC]", "named, with Z"], + ["1970-01-01T00:00Z[!UTC]", "named, with Z and !"], + ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], + ["1970-01-01T00:00Z[!+00:00]", "numeric, with Z and !"], + ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], + ["1970-01-01T00:00+00:00[!UTC]", "named, with offset and !"], + ["1970-01-01T00:00+00:00[+00:00]", "numeric, with offset"], + ["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..a4e81898965 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js @@ -0,0 +1,40 @@ +// 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.withplaindate +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + assert.sameValue( + result.epochNanoseconds, + 957_225_600_000_000_000n, + `time zone annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..08abc6d058e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js @@ -0,0 +1,48 @@ +// 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.withplaintime +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[Asia/Kolkata]", "named, with no offset"], + ["12:34:56.987654321[!Europe/Vienna]", "named, with ! and no offset"], + ["12:34:56.987654321[+00:00]", "numeric, with no offset"], + ["12:34:56.987654321[!-02:30]", "numeric, with ! and no offset"], + ["T12:34:56.987654321[UTC]", "named, with T and no offset"], + ["T12:34:56.987654321[!Africa/Abidjan]", "named, with T, !, and no offset"], + ["T12:34:56.987654321[+01:00]", "numeric, with T and no offset"], + ["T12:34:56.987654321[!-08:00]", "numeric, with T, !, and no offset"], + ["12:34:56.987654321+00:00[America/Sao_Paulo]", "named, with offset"], + ["12:34:56.987654321+00:00[!Asia/Tokyo]", "named, with ! and offset"], + ["12:34:56.987654321+00:00[-02:30]", "numeric, with offset"], + ["12:34:56.987654321+00:00[!+00:00]", "numeric, with ! and offset"], + ["T12:34:56.987654321+00:00[America/New_York]", "named, with T and offset"], + ["T12:34:56.987654321+00:00[!UTC]", "named, with T, !, and offset"], + ["T12:34:56.987654321+00:00[-08:00]", "numeric, with T and offset"], + ["T12:34:56.987654321+00:00[!+01:00]", "numeric, with T, !, and offset"], + ["1970-01-01T12:34:56.987654321[Africa/Lagos]", "named, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!America/Vancouver]", "named, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321[+00:00]", "numeric, with date and no offset"], + ["1970-01-01T12:34:56.987654321[!-02:30]", "numeric, with date, !, and no offset"], + ["1970-01-01T12:34:56.987654321+00:00[Europe/London]", "named, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!Asia/Seoul]", "named, with date, offset, and !"], + ["1970-01-01T12:34:56.987654321+00:00[+01:00]", "numeric, with date and offset"], + ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + assert.sameValue( + result.epochNanoseconds, + 45_296_987_654_321n, + `time zone annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..2a4ac233cbc --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.era +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.era(arg); + + assert.sameValue( + result, + undefined, + `time zone annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js new file mode 100644 index 00000000000..efe71d875e5 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js @@ -0,0 +1,39 @@ +// 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.calendar.prototype.erayear +description: Various forms of time zone annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[Asia/Kolkata]", "named, with no time and no offset"], + ["2000-05-02[!Europe/Vienna]", "named, with !, no time, and no offset"], + ["2000-05-02[+00:00]", "numeric, with no time and no offset"], + ["2000-05-02[!-02:30]", "numeric, with !, no time, and no offset"], + ["2000-05-02+00:00[UTC]", "named, with offset and no time"], + ["2000-05-02+00:00[!Africa/Abidjan]", "named, with offset, !, and no time"], + ["2000-05-02+00:00[-08:00]", "numeric, with offset and no time"], + ["2000-05-02+00:00[!+01:00]", "numeric, with offset, !, and no time"], + ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], + ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], + ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], + ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], + ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], + ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], + ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], + ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.eraYear(arg); + + assert.sameValue( + result, + undefined, + `time zone annotation (${description})` + ); +}); From 216106e746eb886577d3b3ea24beba315ae3b827 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 15:44:31 -0700 Subject: [PATCH 03/11] Temporal: Add tests for calendar annotation with critical flag See https://github.com/tc39/proposal-temporal/pull/2397 Adds tests for ISO strings with calendar annotations, with and without the critical flag, and also a check that the second calendar annotation is disregarded, as per the IETF draft. --- .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 38 +++++++++++++++++++ .../argument-string-calendar-annotation.js | 37 ++++++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 27 +++++++++++++ .../argument-string-calendar-annotation.js | 28 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 38 +++++++++++++++++++ .../argument-string-calendar-annotation.js | 28 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 35 +++++++++++++++++ .../argument-string-calendar-annotation.js | 36 ++++++++++++++++++ .../argument-string-calendar-annotation.js | 37 ++++++++++++++++++ .../argument-string-calendar-annotation.js | 38 +++++++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 38 +++++++++++++++++++ .../argument-string-calendar-annotation.js | 27 +++++++++++++ .../argument-string-calendar-annotation.js | 28 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 30 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 25 ++++++++++++ .../argument-string-calendar-annotation.js | 25 ++++++++++++ .../argument-string-calendar-annotation.js | 28 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 29 ++++++++++++++ .../argument-string-calendar-annotation.js | 32 ++++++++++++++++ .../argument-string-calendar-annotation.js | 38 +++++++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ .../argument-string-calendar-annotation.js | 31 +++++++++++++++ 63 files changed, 1963 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Instant/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..90decf88f54 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.calendar.prototype.dateadd +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateAdd(arg, new Temporal.Duration()); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..0817c8e16bf --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.calendar.prototype.dateuntil +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateUntil(arg, arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f32c36f8e43 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.day +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.day(arg); + + assert.sameValue( + result, + 2, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..ce9230d65f5 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.dayofweek +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfWeek(arg); + + assert.sameValue( + result, + 2, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..0d0e1511b62 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.dayofyear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfYear(arg); + + assert.sameValue( + result, + 123, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..28feba274df --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.daysinmonth +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInMonth(arg); + + assert.sameValue( + result, + 31, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..00da31048af --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.daysinweek +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInWeek(arg); + + assert.sameValue( + result, + 7, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..20880a6f065 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.daysinyear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInYear(arg); + + assert.sameValue( + result, + 366, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e82961e7be4 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.inleapyear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.inLeapYear(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f7da6d3d504 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.month +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.month(arg); + + assert.sameValue( + result, + 5, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..4505d52dbfc --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.monthcode +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthCode(arg); + + assert.sameValue( + result, + "M05", + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..ee88ab9824b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.monthsinyear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthsInYear(arg); + + assert.sameValue( + result, + 12, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..9bf2a295667 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.weekofyear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.weekOfYear(arg); + + assert.sameValue( + result, + 18, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..7132ec6e10e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.year +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.year(arg); + + assert.sameValue( + result, + 2000, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..4c11f5f8321 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Instant/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..3b5310c090a --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.from(arg); + + assert.sameValue( + result.epochNanoseconds, + 0n, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..fb4f3a39cfb --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..8056b73b985 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..7887c615132 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..2b6387d693d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..617ac7eb7ed --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.from(arg); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f92904cc57c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..68279b7f3dd --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..0c6512df1af --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-calendar-annotation.js @@ -0,0 +1,38 @@ +// 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.toplaindatetime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..69563d510eb --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-calendar-annotation.js @@ -0,0 +1,37 @@ +// 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.tozoneddatetime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..a3242732220 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f98f1b7757c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-calendar-annotation.js @@ -0,0 +1,27 @@ +// 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.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e5709ad371e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-string-calendar-annotation.js @@ -0,0 +1,28 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.from(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 15, 23, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..1a09f0aad5c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..aa14181bf7f --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..56d241fdd57 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..aa414240bf0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.withplaindate +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..08450416e58 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js @@ -0,0 +1,38 @@ +// 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.withplaintime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..54dcdfe9e20 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-calendar-annotation.js @@ -0,0 +1,28 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["1976-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainMonthDay.from(arg); + + TemporalHelpers.assertPlainMonthDay( + result, + "M05", 2, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..1da1eb37d79 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["1976-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainMonthDay(5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..ea387f7d834 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-calendar-annotation.js @@ -0,0 +1,35 @@ +// 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.plaintime.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..b15e34bf4de --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-calendar-annotation.js @@ -0,0 +1,36 @@ +// 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.plaintime.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.from(arg); + + TemporalHelpers.assertPlainTime( + result, + 12, 34, 56, 987, 654, 321, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..1803cce00ef --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,37 @@ +// 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.plaintime.prototype.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..eac24b18f90 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,38 @@ +// 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.plaintime.prototype.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..40950a0b99b --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.plaintime.prototype.toplaindatetime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..c32a12c35ae --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.plaintime.prototype.tozoneddatetime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..4d2f6c0c4c0 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,38 @@ +// 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.plaintime.prototype.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..ca15d7067df --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-calendar-annotation.js @@ -0,0 +1,27 @@ +// 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.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[u-ca=iso8601]", "without time zone"], + ["2019-12-15T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2019-12-15T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2019-12-15T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2019-12-15T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2019-12-15T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..c0a5c4dc2a9 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-calendar-annotation.js @@ -0,0 +1,28 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[u-ca=iso8601]", "without time zone"], + ["2019-12-15T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2019-12-15T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2019-12-15T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2019-12-15T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2019-12-15T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.from(arg); + + TemporalHelpers.assertPlainYearMonth( + result, + 2019, 12, "M12", + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e94d368392d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[u-ca=iso8601]", "without time zone"], + ["2019-12-15T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2019-12-15T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2019-12-15T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2019-12-15T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2019-12-15T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..be7dc5dcd09 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[u-ca=iso8601]", "without time zone"], + ["2019-12-15T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2019-12-15T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2019-12-15T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2019-12-15T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2019-12-15T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f764083c590 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[u-ca=iso8601]", "without time zone"], + ["2019-12-15T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2019-12-15T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2019-12-15T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2019-12-15T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2019-12-15T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..1ae9e99b8bf --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.timezone.prototype.getinstantfor +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getInstantFor(arg); + + assert.sameValue( + result.epochNanoseconds, + 217_178_580_000_000_000n, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e655390e68f --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getnexttransition +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getNextTransition(arg); + + assert.sameValue( + result, + null, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..8bb055bb2b7 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getoffsetnanosecondsfor +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetNanosecondsFor(arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..17b5c0076e7 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getoffsetstringfor +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetStringFor(arg); + + assert.sameValue( + result, + "+00:00", + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..4a7191a1464 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.timezone.prototype.getplaindatetimefor +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPlainDateTimeFor(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..313685f5ba0 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js @@ -0,0 +1,30 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [compareArray.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], + ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1976-11-18T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPossibleInstantsFor(arg); + + assert.compareArray( + result.map(i => i.epochNanoseconds), + [217_178_580_000_000_000n], + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e01352ea539 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.timezone.prototype.getprevioustransition +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], + ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], + ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], + ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], + ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], + ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], + ["1970-01-01T00:00Z[u-ca=iso8601][!u-ca=discord]", "two annotations are ignored even with !"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPreviousTransition(arg); + + assert.sameValue( + result, + null, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..63075d2efa4 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-calendar-annotation.js @@ -0,0 +1,25 @@ +// 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.compare +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][u-ca=iso8601]", "without !"], + ["1970-01-01T00:00[UTC][!u-ca=iso8601]", "with !"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.ZonedDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..8bf82dcaf1c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-calendar-annotation.js @@ -0,0 +1,25 @@ +// 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.from +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][u-ca=iso8601]", "without !"], + ["1970-01-01T00:00[UTC][!u-ca=iso8601]", "with !"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.ZonedDateTime.from(arg); + + assert.sameValue( + result.calendar.toString(), + "iso8601", + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..ada074e5d4c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][u-ca=iso8601]", "without !"], + ["1970-01-01T00:00[UTC][!u-ca=iso8601]", "with !"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..1797eb7b50d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.since +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][u-ca=iso8601]", "without !"], + ["1970-01-01T00:00[UTC][!u-ca=iso8601]", "with !"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..eebcfa79b70 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js @@ -0,0 +1,29 @@ +// 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.until +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][u-ca=iso8601]", "without !"], + ["1970-01-01T00:00[UTC][!u-ca=iso8601]", "with !"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..0d25c4c3d00 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js @@ -0,0 +1,32 @@ +// 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.withplaindate +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + assert.sameValue( + result.epochNanoseconds, + 957_225_600_000_000_000n, + `calendar annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..f18dc778d53 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js @@ -0,0 +1,38 @@ +// 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.withplaintime +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[u-ca=iso8601]", "without time zone"], + ["12:34:56.987654321[UTC][u-ca=iso8601]", "with time zone"], + ["12:34:56.987654321[!u-ca=iso8601]", "with ! and no time zone"], + ["12:34:56.987654321[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["T12:34:56.987654321[u-ca=iso8601]", "with T and no time zone"], + ["T12:34:56.987654321[UTC][u-ca=iso8601]", "with T and time zone"], + ["T12:34:56.987654321[!u-ca=iso8601]", "with T, !, and no time zone"], + ["T12:34:56.987654321[UTC][!u-ca=iso8601]", "with T, !, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601]", "with date and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][u-ca=iso8601]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[!u-ca=iso8601]", "with !, date, and no time zone"], + ["1970-01-01T12:34:56.987654321[UTC][!u-ca=iso8601]", "with !, date, and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + assert.sameValue( + result.epochNanoseconds, + 45_296_987_654_321n, + `calendar annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..68b6b81534c --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.era +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.era(arg); + + assert.sameValue( + result, + undefined, + `calendar annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js new file mode 100644 index 00000000000..e2221c807eb --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js @@ -0,0 +1,31 @@ +// 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.calendar.prototype.erayear +description: Various forms of calendar annotation; critical flag has no effect +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[u-ca=iso8601]", "without time or time zone"], + ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], + ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], + ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], + ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], + ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], + ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], + ["2000-05-02T15:23[u-ca=iso8601][!u-ca=discord]", "second annotation ignored even with !"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.eraYear(arg); + + assert.sameValue( + result, + undefined, + `calendar annotation (${description})` + ); +}); From 52663bd07f0d3ec22217189ae014bc56048c46df Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 16:07:57 -0700 Subject: [PATCH 04/11] Temporal: Add tests for unknown annotation without critical flag See https://github.com/tc39/proposal-temporal/pull/2397 Adds tests for ISO strings with unrecognized annotations, (i.e., neither time zone nor calendar), in various combinations with recognized annotations. --- .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../day/argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 26 +++++++++++++ .../argument-string-unknown-annotation.js | 26 +++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 27 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 37 +++++++++++++++++++ .../argument-string-unknown-annotation.js | 36 ++++++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 26 +++++++++++++ .../argument-string-unknown-annotation.js | 27 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 37 +++++++++++++++++++ .../argument-string-unknown-annotation.js | 27 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 34 +++++++++++++++++ .../argument-string-unknown-annotation.js | 35 ++++++++++++++++++ .../argument-string-unknown-annotation.js | 36 ++++++++++++++++++ .../argument-string-unknown-annotation.js | 37 +++++++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 37 +++++++++++++++++++ .../argument-string-unknown-annotation.js | 26 +++++++++++++ .../argument-string-unknown-annotation.js | 27 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 25 +++++++++++++ .../argument-string-unknown-annotation.js | 25 +++++++++++++ .../argument-string-unknown-annotation.js | 28 ++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 30 +++++++++++++++ .../argument-string-unknown-annotation.js | 37 +++++++++++++++++++ .../era/argument-string-unknown-annotation.js | 29 +++++++++++++++ .../argument-string-unknown-annotation.js | 29 +++++++++++++++ 63 files changed, 1860 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..d285863cbd5 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.calendar.prototype.dateadd +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateAdd(arg, new Temporal.Duration()); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..3b83c67e5fb --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.calendar.prototype.dateuntil +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dateUntil(arg, arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..40038e90dac --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.day +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.day(arg); + + assert.sameValue( + result, + 2, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..806494ecf37 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.dayofweek +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfWeek(arg); + + assert.sameValue( + result, + 2, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..dbeb37d96f8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.dayofyear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.dayOfYear(arg); + + assert.sameValue( + result, + 123, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..8541062e59f --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.daysinmonth +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInMonth(arg); + + assert.sameValue( + result, + 31, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..56f900bb369 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.daysinweek +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInWeek(arg); + + assert.sameValue( + result, + 7, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..12c900339c3 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.daysinyear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.daysInYear(arg); + + assert.sameValue( + result, + 366, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..539fe4533a8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.inleapyear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.inLeapYear(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..6a966dfced8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.month +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.month(arg); + + assert.sameValue( + result, + 5, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..ed3ef4d428e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.monthcode +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthCode(arg); + + assert.sameValue( + result, + "M05", + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..118150626ed --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.monthsinyear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.monthsInYear(arg); + + assert.sameValue( + result, + 12, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..951d276a1c8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.weekofyear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.weekOfYear(arg); + + assert.sameValue( + result, + 18, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..e6ab34eeeeb --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.year +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.year(arg); + + assert.sameValue( + result, + 2000, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Instant/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..08c761a6dd1 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/argument-string-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Instant/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..f51a241adca --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/argument-string-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.Instant.from(arg); + + assert.sameValue( + result.epochNanoseconds, + 0n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..2d1ee64f9f3 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..0c032c524aa --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..2816b6035af --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Instant(0n); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..9bd1428f74f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-string-unknown-annotation.js @@ -0,0 +1,27 @@ +// 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.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..f08ca2ca9fd --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDate.from(arg); + + TemporalHelpers.assertPlainDate( + result, + 2000, 5, "M05", 2, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..9eefcba2125 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..a1f9dab3850 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..482a705eeba --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-unknown-annotation.js @@ -0,0 +1,37 @@ +// 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.toplaindatetime +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..3ac8970b0a0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-unknown-annotation.js @@ -0,0 +1,36 @@ +// 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.tozoneddatetime +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..221f1cf733e --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..f4be81345ff --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..49b2dfc4336 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-string-unknown-annotation.js @@ -0,0 +1,27 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainDateTime.from(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 15, 23, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..eceefb2b92e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..28220cd8e3d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..e5cb615127a --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..1071909235b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.withplaindate +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..307b1ba9ab9 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js @@ -0,0 +1,37 @@ +// 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.withplaintime +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..263377f4a36 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-unknown-annotation.js @@ -0,0 +1,27 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1976-05-02T15:23[foo=bar]", "alone"], + ["1976-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["1976-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainMonthDay.from(arg); + + TemporalHelpers.assertPlainMonthDay( + result, + "M05", 2, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..bbed2a0c751 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1976-05-02T15:23[foo=bar]", "alone"], + ["1976-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["1976-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainMonthDay(5, 2); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..0c7069446aa --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-unknown-annotation.js @@ -0,0 +1,34 @@ +// 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.plaintime.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..9ef22988fb3 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-unknown-annotation.js @@ -0,0 +1,35 @@ +// 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.plaintime.from +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainTime.from(arg); + + TemporalHelpers.assertPlainTime( + result, + 12, 34, 56, 987, 654, 321, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..4c4323d0695 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,36 @@ +// 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.plaintime.prototype.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..8cf94c1edc5 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,37 @@ +// 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.plaintime.prototype.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..e8814197582 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.plaintime.prototype.toplaindatetime +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toPlainDateTime(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..2c829f70769 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.plaintime.prototype.tozoneddatetime +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); + + assert.sameValue( + result.epochNanoseconds, + 957_270_896_987_654_321n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..2a6f5ff3cc0 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,37 @@ +// 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.plaintime.prototype.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..af273efc943 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[foo=bar]", "alone"], + ["2019-12-15T15:23[UTC][foo=bar]", "with time zone"], + ["2019-12-15T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2019-12-15T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2019-12-15T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..7a1a5b915e7 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-unknown-annotation.js @@ -0,0 +1,27 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[foo=bar]", "alone"], + ["2019-12-15T15:23[UTC][foo=bar]", "with time zone"], + ["2019-12-15T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2019-12-15T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2019-12-15T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.PlainYearMonth.from(arg); + + TemporalHelpers.assertPlainYearMonth( + result, + 2019, 12, "M12", + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..7a6a52aa5a1 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2019-12-15T15:23[foo=bar]", "alone"], + ["2019-12-15T15:23[UTC][foo=bar]", "with time zone"], + ["2019-12-15T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2019-12-15T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2019-12-15T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..60870ca4827 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[foo=bar]", "alone"], + ["2019-12-15T15:23[UTC][foo=bar]", "with time zone"], + ["2019-12-15T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2019-12-15T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2019-12-15T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..365c2bd84de --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["2019-12-15T15:23[foo=bar]", "alone"], + ["2019-12-15T15:23[UTC][foo=bar]", "with time zone"], + ["2019-12-15T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2019-12-15T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2019-12-15T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.PlainYearMonth(2019, 12); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..91bb85df9f5 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.timezone.prototype.getinstantfor +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getInstantFor(arg); + + assert.sameValue( + result.epochNanoseconds, + 217_178_580_000_000_000n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..53f49b74b99 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.timezone.prototype.getnexttransition +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getNextTransition(arg); + + assert.sameValue( + result, + null, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..1534172c6ac --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.timezone.prototype.getoffsetnanosecondsfor +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetNanosecondsFor(arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..46666bda446 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.timezone.prototype.getoffsetstringfor +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getOffsetStringFor(arg); + + assert.sameValue( + result, + "+00:00", + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..89983064f38 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.timezone.prototype.getplaindatetimefor +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPlainDateTimeFor(arg); + + TemporalHelpers.assertPlainDateTime( + result, + 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..dd94565cc5c --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.timezone.prototype.getpossibleinstantsfor +description: Various forms of unknown annotation +features: [Temporal] +includes: [compareArray.js] +---*/ + +const tests = [ + ["1976-11-18T15:23[foo=bar]", "alone"], + ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], + ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPossibleInstantsFor(arg); + + assert.compareArray( + result.map(i => i.epochNanoseconds), + [217_178_580_000_000_000n], + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..7d964fba19a --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.timezone.prototype.getprevioustransition +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00Z[foo=bar]", "alone"], + ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], + ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.TimeZone("UTC"); + +tests.forEach(([arg, description]) => { + const result = instance.getPreviousTransition(arg); + + assert.sameValue( + result, + null, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..8c9b5800814 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.compare +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00[UTC][foo=bar][u-ca=iso8601]", "before calendar"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar]", "after calendar"], + ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.ZonedDateTime.compare(arg, arg); + + assert.sameValue( + result, + 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..229abfa2205 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.from +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00[UTC][foo=bar][u-ca=iso8601]", "before calendar"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar]", "after calendar"], + ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +tests.forEach(([arg, description]) => { + const result = Temporal.ZonedDateTime.from(arg); + + assert.sameValue( + result.epochNanoseconds, + 0n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..eb815b4d71f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js @@ -0,0 +1,28 @@ +// 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.equals +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00[UTC][foo=bar][u-ca=iso8601]", "before calendar"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar]", "after calendar"], + ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.equals(arg); + + assert.sameValue( + result, + true, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..8e3b643be9c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.since +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00[UTC][foo=bar][u-ca=iso8601]", "before calendar"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar]", "after calendar"], + ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.since(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..471ef894156 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.until +description: Various forms of unknown annotation +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const tests = [ + ["1970-01-01T00:00[UTC][foo=bar]", "with time zone"], + ["1970-01-01T00:00[UTC][foo=bar][u-ca=iso8601]", "before calendar"], + ["1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar]", "after calendar"], + ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.until(arg); + + TemporalHelpers.assertDuration( + result, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..d07b5c627e5 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.withplaindate +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainDate(arg); + + assert.sameValue( + result.epochNanoseconds, + 957_225_600_000_000_000n, + `unknown annotation (${description})` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..f5e4e9395c2 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js @@ -0,0 +1,37 @@ +// 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.withplaintime +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["12:34:56.987654321[foo=bar]", "alone"], + ["12:34:56.987654321[UTC][foo=bar]", "with time zone"], + ["12:34:56.987654321[u-ca=iso8601][foo=bar]", "with calendar"], + ["12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["T12:34:56.987654321[foo=bar]", "with T"], + ["T12:34:56.987654321[UTC][foo=bar]", "with T and time zone"], + ["T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with T and calendar"], + ["T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with T, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar]", "with date"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar]", "with date and time zone"], + ["1970-01-01T12:34:56.987654321[u-ca=iso8601][foo=bar]", "with date and calendar"], + ["1970-01-01T12:34:56.987654321[UTC][foo=bar][u-ca=iso8601]", "with date, time zone, and calendar"], + ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +tests.forEach(([arg, description]) => { + const result = instance.withPlainTime(arg); + + assert.sameValue( + result.epochNanoseconds, + 45_296_987_654_321n, + `unknown annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..940ea78fa38 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.era +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.era(arg); + + assert.sameValue( + result, + undefined, + `unknown annotation (${description})` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js new file mode 100644 index 00000000000..d98a8537b09 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.calendar.prototype.erayear +description: Various forms of unknown annotation +features: [Temporal] +---*/ + +const tests = [ + ["2000-05-02[foo=bar]", "without time"], + ["2000-05-02T15:23[foo=bar]", "alone"], + ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], + ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], + ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], + ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], +]; + +const instance = new Temporal.Calendar("iso8601"); + +tests.forEach(([arg, description]) => { + const result = instance.eraYear(arg); + + assert.sameValue( + result, + undefined, + `unknown annotation (${description})` + ); +}); From 3aba1d19c6ba9a765c26cf8aa7e183f18e583b0f Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 16:27:15 -0700 Subject: [PATCH 05/11] Temporal: Add tests for unknown annotation with critical flag See https://github.com/tc39/proposal-temporal/pull/2397 Adds tests for ISO strings with unrecognized annotations with the critical flag. These strings should all be rejected. --- ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 30 ++++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 31 +++++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 30 ++++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 29 +++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 31 +++++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 29 +++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 30 ++++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 23 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 24 ++++++++++++++ ...ment-string-critical-unknown-annotation.js | 26 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 27 ++++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ ...ment-string-critical-unknown-annotation.js | 25 +++++++++++++++ 63 files changed, 1594 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..f165c8f2ee1 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dateadd +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateAdd(arg, new Temporal.Duration()), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..1efacbd80e5 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.calendar.prototype.dateuntil +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..028bdf0b94c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.day +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.day(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..8b24b8afd5d --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dayofweek +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfWeek(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..cdccc47fec8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dayofyear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..bfd23689e38 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinmonth +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInMonth(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..d6a7f654750 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinweek +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInWeek(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..65a7981d01e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinyear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..6387d90667a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.inleapyear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.inLeapYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..0e7b9ed0994 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.month +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.month(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..ee3e52cddb6 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.monthcode +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthCode(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..f7de7fc9360 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.monthsinyear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthsInYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..3912c159072 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.weekofyear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.weekOfYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..0d5e92f9fac --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.year +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.year(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Instant/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..31bde5409d6 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,31 @@ +// 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.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +const epoch = new Temporal.Instant(0n); + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.Instant.compare(arg, epoch), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.Instant.compare(epoch, arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Instant/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..c994075bf41 --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/argument-string-critical-unknown-annotation.js @@ -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.instant.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.Instant.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..4aeff55683b --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-critical-unknown-annotation.js @@ -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.instant.prototype.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..464ee8e37e5 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/argument-string-critical-unknown-annotation.js @@ -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.instant.prototype.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Instant/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..b5c559a7afb --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/argument-string-critical-unknown-annotation.js @@ -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.instant.prototype.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..555d4cf7561 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..ea8840b0366 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..5a2a62d35f0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..a0f43b18e3b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..3b7c31e3d7d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.toplaindatetime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..bcfbd29488c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.tozoneddatetime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..e34303e8e68 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..83e0c6763af --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..4862f56696e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-string-critical-unknown-annotation.js @@ -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.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..892e592a3fe --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-critical-unknown-annotation.js @@ -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.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..38db547fa6b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-critical-unknown-annotation.js @@ -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.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..2df877ccf02 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-critical-unknown-annotation.js @@ -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.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..54f071da91e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.withplaindate +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..34c21eefd43 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.withplaintime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..d0d71734cc0 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-critical-unknown-annotation.js @@ -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.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..dfa7a3ace4e --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-critical-unknown-annotation.js @@ -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.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainMonthDay(5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..4625312d09d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,31 @@ +// 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.plaintime.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..51df21a3aa9 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.plaintime.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..8ffe48133f4 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..a41824557bc --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..cc0677cf384 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.plaintime.prototype.toplaindatetime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..243bedfad1d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.plaintime.prototype.tozoneddatetime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..769ef40e977 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..a6813f74e09 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,29 @@ +// 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.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..ab80f1122cd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-critical-unknown-annotation.js @@ -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.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..cf6c306d05f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-critical-unknown-annotation.js @@ -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.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..7bb6baaf892 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-critical-unknown-annotation.js @@ -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.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..f30c6b004f8 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-critical-unknown-annotation.js @@ -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.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..561a17da8ff --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getinstantfor +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getInstantFor(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..d805a9438d6 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getnexttransition +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getNextTransition(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..612c9cba7db --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getoffsetnanosecondsfor +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetNanosecondsFor(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..bd0210330c7 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getoffsetstringfor +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetStringFor(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..b527f247ad0 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getplaindatetimefor +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPlainDateTimeFor(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..972e3b4e30b --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getpossibleinstantsfor +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPossibleInstantsFor(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..527c45e2dd1 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js @@ -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.timezone.prototype.getprevioustransition +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar]", + "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPreviousTransition(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..fa21bffb8ed --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-critical-unknown-annotation.js @@ -0,0 +1,30 @@ +// 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.compare +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(arg, datetime), + `reject unknown annotation with critical flag: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, arg), + `reject unknown annotation with critical flag: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..ba0a3568764 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-critical-unknown-annotation.js @@ -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.from +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..c1fcd5403a1 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js @@ -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.equals +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..b7b184ddd0c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js @@ -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.since +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..a29b7bc4c81 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js @@ -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.until +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..4be359871c9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js @@ -0,0 +1,26 @@ +// 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.withplaindate +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..3ae28dfd0c1 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js @@ -0,0 +1,27 @@ +// 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.withplaintime +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[!foo=bar]", + "T00:00[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..94613036ae4 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.era +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.era(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js new file mode 100644 index 00000000000..c1af895dc21 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.erayear +description: Unknown annotations with critical flag are rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[!foo=bar]", + "1970-01-01T00:00[!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar]", + "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", + "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", + "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.eraYear(arg), + `reject unknown annotation with critical flag: ${arg}` + ); +}); From 149c5e65a001dd426f518e88b13e8050a716fb85 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 16:47:50 -0700 Subject: [PATCH 06/11] Temporal: Add tests for multiple time zone annotations See https://github.com/tc39/proposal-temporal/pull/2397 Adds tests for ISO strings with more than one time zone annotation. These are not syntactically correct according to the grammar and should be rejected. --- .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 30 ++++++++++++++++++ .../day/argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 31 +++++++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 30 ++++++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 29 +++++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 31 +++++++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 29 +++++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 31 +++++++++++++++++++ .../argument-string-multiple-time-zone.js | 24 ++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 26 ++++++++++++++++ .../argument-string-multiple-time-zone.js | 27 ++++++++++++++++ .../era/argument-string-multiple-time-zone.js | 25 +++++++++++++++ .../argument-string-multiple-time-zone.js | 25 +++++++++++++++ 63 files changed, 1599 insertions(+) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Instant/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Instant/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/compare/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js create mode 100644 test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js create mode 100644 test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c7983c88031 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dateadd +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateAdd(arg, new Temporal.Duration()), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..80a55915b3b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js @@ -0,0 +1,30 @@ +// 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.calendar.prototype.dateuntil +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..252ed87a442 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.day +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.day(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..33393f9c754 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dayofweek +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfWeek(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..8dd85df4bfd --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.dayofyear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..fd86a9be34a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinmonth +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInMonth(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..43af6dac0cd --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinweek +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInWeek(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..e91a96ca07a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.daysinyear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..253a580aa60 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.inleapyear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.inLeapYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..95197fb917f --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.month +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.month(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c522cdcd286 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.monthcode +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthCode(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..d411ff9c962 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.monthsinyear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthsInYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..7619b36d054 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.weekofyear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.weekOfYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..5716b9abca4 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.year +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.year(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Instant/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..f45e67533a4 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,31 @@ +// 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.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; + +const epoch = new Temporal.Instant(0n); + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.Instant.compare(arg, epoch), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.Instant.compare(epoch, arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Instant/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..71b87fd9d6f --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/argument-string-multiple-time-zone.js @@ -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.instant.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.Instant.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..122373efa78 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/argument-string-multiple-time-zone.js @@ -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.instant.prototype.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Instant/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..5658b91ba46 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/argument-string-multiple-time-zone.js @@ -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.instant.prototype.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Instant/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..5b8f679c06c --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/argument-string-multiple-time-zone.js @@ -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.instant.prototype.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..db03cab232c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,30 @@ +// 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.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..7f47f178c78 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..0b490655b19 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..88cf32d5e9c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c1cfa146d2f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.toplaindatetime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..9d3818c2a19 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.tozoneddatetime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..557f461f4c8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c821717eacc --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,29 @@ +// 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.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..f5fdc6c4b46 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-string-multiple-time-zone.js @@ -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.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..8e59cb125e6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-multiple-time-zone.js @@ -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.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..1808820b21e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-multiple-time-zone.js @@ -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.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..98f7b78c5d7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-multiple-time-zone.js @@ -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.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..2b84ca0cdf7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.withplaindate +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..f9533d181e0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.withplaintime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..a075e2fcb6f --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-string-multiple-time-zone.js @@ -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.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c05d4364713 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-string-multiple-time-zone.js @@ -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.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainMonthDay(5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..79736c44366 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,31 @@ +// 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.plaintime.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..461c158f2fe --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.plaintime.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..382925e537d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..6a5cd3cc4de --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..f9ec99ba89a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.plaintime.prototype.toplaindatetime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..bddfb924ee5 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.plaintime.prototype.tozoneddatetime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..ae2a2141da0 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.plaintime.prototype.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..ca1b855477b --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,29 @@ +// 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.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..04e83b31717 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string-multiple-time-zone.js @@ -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.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..ff61b6ba7b4 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-multiple-time-zone.js @@ -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.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..9ec09480a6a --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-multiple-time-zone.js @@ -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.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..3f9fa06458f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-multiple-time-zone.js @@ -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.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..5e6509414ba --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getinstantfor +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getInstantFor(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..ec245c5a685 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getnexttransition +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getNextTransition(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..2739414d204 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getoffsetnanosecondsfor +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetNanosecondsFor(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..080c8119adc --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getoffsetstringfor +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetStringFor(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..875971d3304 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getplaindatetimefor +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPlainDateTimeFor(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..4b0ddfa2ca6 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getpossibleinstantsfor +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPossibleInstantsFor(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..64aa91d2941 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js @@ -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.timezone.prototype.getprevioustransition +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00Z[UTC][UTC]", + "1970-01-01T00:00Z[!UTC][UTC]", + "1970-01-01T00:00Z[UTC][!UTC]", + "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00Z[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPreviousTransition(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..7b963c056d3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-string-multiple-time-zone.js @@ -0,0 +1,31 @@ +// 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.compare +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(arg, datetime), + `reject more than one time zone annotation: ${arg} (first argument)` + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, arg), + `reject more than one time zone annotation: ${arg} (second argument)` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..019ebf4be4e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-string-multiple-time-zone.js @@ -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.from +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..642bb280c27 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.equals +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..c5c328d3c65 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.since +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..5a9d0c16bcb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.until +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..a8b1fb1c2b2 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js @@ -0,0 +1,26 @@ +// 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.withplaindate +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..56a8c763429 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js @@ -0,0 +1,27 @@ +// 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.withplaintime +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "00:00[UTC][UTC]", + "T00:00[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..ac43caa1aeb --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.era +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.era(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js new file mode 100644 index 00000000000..a0ad58f7a9b --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js @@ -0,0 +1,25 @@ +// 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.calendar.prototype.erayear +description: More than one time zone annotation is not syntactical +features: [Temporal] +---*/ + +const invalidStrings = [ + "1970-01-01[UTC][UTC]", + "1970-01-01T00:00[UTC][UTC]", + "1970-01-01T00:00[!UTC][UTC]", + "1970-01-01T00:00[UTC][!UTC]", + "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", + "1970-01-01T00:00[UTC][foo=bar][UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.eraYear(arg), + `reject more than one time zone annotation: ${arg}` + ); +}); From 86a37474d4628f14cec75a2be025b436dff5ed9e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 18:06:30 -0700 Subject: [PATCH 07/11] Temporal: Expand and regularize existing calendarName option tests Since we are going to be adding a new test for calendarName: "critical", take the existing tests for various values of the calendarName option, and regularize them. Previously, depending on which type's toString() method was under test, the tests had various degrees of thoroughness, and some were only present in staging. --- .../prototype/toString/calendar-tostring.js | 6 +-- .../prototype/toString/calendarname-always.js | 31 +++++++-------- .../prototype/toString/calendarname-auto.js | 31 +++++++-------- .../toString/calendarname-invalid-string.js | 10 +++-- .../prototype/toString/calendarname-never.js | 31 +++++++-------- .../toString/calendarname-undefined.js | 29 +++++++------- .../prototype/toString/calendar-tostring.js | 6 +-- .../prototype/toString/calendarname-always.js | 20 ++++++---- .../prototype/toString/calendarname-auto.js | 39 +++++++------------ .../toString/calendarname-invalid-string.js | 11 +++--- .../prototype/toString/calendarname-never.js | 30 +++++++------- .../toString/calendarname-undefined.js | 27 +++++++------ .../prototype/toString/calendar-tostring.js | 28 +++++++++++++ .../prototype/toString/calendarname-always.js | 18 ++++----- .../prototype/toString/calendarname-auto.js | 18 ++++----- .../toString/calendarname-invalid-string.js | 10 ++++- .../prototype/toString/calendarname-never.js | 18 ++++----- .../toString/calendarname-undefined.js | 20 +++++----- .../prototype/toString/calendar-tostring.js | 28 +++++++++++++ .../prototype/toString/calendarname-always.js | 26 ++++++------- .../prototype/toString/calendarname-auto.js | 26 ++++++------- .../toString/calendarname-invalid-string.js | 10 ++++- .../prototype/toString/calendarname-never.js | 26 ++++++------- .../toString/calendarname-undefined.js | 28 +++++++------ .../prototype/toString/calendar-tostring.js | 16 ++++---- .../prototype/toString/calendarname-always.js | 22 +++++++++++ .../prototype/toString/calendarname-auto.js | 22 +++++++++++ .../toString/calendarname-invalid-string.js | 12 +++++- .../prototype/toString/calendarname-never.js | 22 +++++++++++ .../toString/calendarname-undefined.js | 28 +++++++------ .../Temporal/ZonedDateTime/old/toString.js | 19 --------- 31 files changed, 386 insertions(+), 282 deletions(-) create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js index 75a2e03fbf2..38f5573938d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindate.protoype.tostring -description: Should call 'toString' on the calendar once unless calendarName == 'never'. +description: Number of observable 'toString' calls on the calendar for each value of calendarName features: [Temporal] ---*/ @@ -23,6 +23,6 @@ const date = new Temporal.PlainDate(2000, 5, 2, customCalendar); ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `calendarName = ${calendarName}: expected ${expectedResult}`); - assert.sameValue(calls, expectedCalls, `calendarName = ${calendarName}: expected ${expectedCalls} call(s) to 'toString'`); + assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js index 629955a6640..607a9f660c9 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js @@ -1,23 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring -description: always value for calendarName option +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const customCalendar = { - toString() { return "custom"; } -}; -const customISOCalendar = { - toString() { return "iso8601"; } -}; -[ - [new Temporal.PlainDate(2000, 5, 2), "2000-05-02[u-ca=iso8601]"], - [new Temporal.PlainDate(2000, 5, 2, customCalendar), "2000-05-02[u-ca=custom]"], - [new Temporal.PlainDate(2000, 5, 2, customISOCalendar), "2000-05-02[u-ca=iso8601]"], -].forEach(([date, expected]) => { +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: "always" }); - assert.sameValue(result, expected, "expected " + expected); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js index 7acb8c63c85..c5154ea8a9e 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js @@ -1,23 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring -description: auto value for calendarName option +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const customCalendar = { - toString() { return "custom"; } -}; -const customISOCalendar = { - toString() { return "iso8601"; } -}; -[ - [new Temporal.PlainDate(2000, 5, 2), "2000-05-02"], - [new Temporal.PlainDate(2000, 5, 2, customCalendar), "2000-05-02[u-ca=custom]"], - [new Temporal.PlainDate(2000, 5, 2, customISOCalendar), "2000-05-02"], -].forEach(([date, expected]) => { +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-02[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05-02", "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: "auto" }); - assert.sameValue(result, expected, "expected " + expected); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js index 5491e595bc6..fc476e02876 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js @@ -15,8 +15,12 @@ features: [Temporal] ---*/ const date = new Temporal.PlainDate(2000, 5, 2); -const values = ["ALWAYS", "sometimes", "other string", "auto\0"]; +const invalidValues = ["ALWAYS", "sometimes", "other string", "auto\0"]; -for (const calendarName of values) { - assert.throws(RangeError, () => date.toString({ calendarName })); +for (const calendarName of invalidValues) { + assert.throws( + RangeError, + () => date.toString({ calendarName }), + `${calendarName} is an invalid value for calendarName option` + ); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js index 75fe99b99e5..163ab4eb10a 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js @@ -1,23 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring -description: never value for calendarName option +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const customCalendar = { - toString() { return "custom"; } -}; -const customISOCalendar = { - toString() { return "iso8601"; } -}; -[ - [new Temporal.PlainDate(2000, 5, 2), "2000-05-02"], - [new Temporal.PlainDate(2000, 5, 2, customCalendar), "2000-05-02"], - [new Temporal.PlainDate(2000, 5, 2, customISOCalendar), "2000-05-02"], -].forEach(([date, expected]) => { +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-02", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05-02", "custom with iso8601 toString"], + [[{ toString() { return "ISO8601"; } }], "2000-05-02", "custom with caps toString"], + [[{ toString() { return "\u0131so8601"; } }], "2000-05-02", "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: "never" }); - assert.sameValue(result, expected, "expected " + expected); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js index aa3364c9d3d..fafbd11fd88 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js @@ -14,20 +14,17 @@ info: | features: [Temporal] ---*/ -const customCalendar = { - toString() { return "custom"; } -}; -const customISOCalendar = { - toString() { return "iso8601"; } -}; -[ - [new Temporal.PlainDate(2000, 5, 2), "2000-05-02"], - [new Temporal.PlainDate(2000, 5, 2, customCalendar), "2000-05-02[u-ca=custom]"], - [new Temporal.PlainDate(2000, 5, 2, customISOCalendar), "2000-05-02"], -].forEach(([date, expected]) => { - const explicit = date.toString({ calendarName: undefined }); - assert.sameValue(explicit, expected, "default calendarName option is auto"); +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-02[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05-02", "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"], +]; - const implicit = date.toString({}); - assert.sameValue(implicit, expected, "default calendarName option is auto"); -}); +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js index 9ff60128346..0dc825c8fac 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindatetime.protoype.tostring -description: Should call 'toString' on the calendar once unless calendarName == 'never'. +description: Number of observable 'toString' calls on the calendar for each value of calendarName features: [Temporal] ---*/ @@ -23,6 +23,6 @@ const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, c ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `calendarName = ${calendarName}: expected ${expectedResult}`); - assert.sameValue(calls, expectedCalls, `calendarName = ${calendarName}: expected ${expectedCalls} call(s) to 'toString'`); + assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js index 5ae257d8bd0..a66b1995d31 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js @@ -3,14 +3,20 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Show ISO calendar if calendar name is "always" +description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); +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"], +]; -assert.sameValue( - dt.toString({ calendarName: "always" }), - "1976-11-18T15:23:00[u-ca=iso8601]", - "shows ISO calendar if calendarName = always" -); +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: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js index 7440f549227..c8945caf9b1 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js @@ -3,33 +3,20 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Possibly display calendar when calendarName is "auto" +description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "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"], +]; -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); -const customCal = { - toString() { return "bogus"; } -}; -const fakeISO8601Cal = { - toString() { return "iso8601"; } -}; -const expected = "1976-11-18T15:23:00"; - -assert.sameValue(dt.toString(), expected, "default is calendar = auto (zero arguments)"); -assert.sameValue(dt.toString({ calendarName: "auto" }), expected, "shows only non-ISO calendar if calendarName = auto"); - -assert.sameValue( - dt.withCalendar(fakeISO8601Cal).toString({ calendarName: "auto" }), - expected, - "Don't show ISO calendar even if calendarName = auto" -); - -const dt2 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, customCal); - -assert.sameValue( - dt2.toString({ calendarName: "auto" }), - "1976-11-18T15:23:00[u-ca=bogus]", - "Don't show calendar if calendarName = auto & PlainDateTime has non-ISO calendar" -); +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: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js index e17d9d1e443..6b880f0d3da 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js @@ -15,11 +15,12 @@ features: [Temporal] ---*/ const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const invalidCals = ["other string", "ALWAYS", "sometimes", "auto\0"]; +const invalidValues = ["ALWAYS", "sometimes", "other string", "auto\0"]; -invalidCals.forEach((cal) => { +for (const calendarName of invalidValues) { assert.throws( RangeError, - () => datetime.toString({ calendarName: cal }), - `invalid calendar (${cal})`); -}); + () => datetime.toString({ calendarName }), + `${calendarName} is an invalid value for calendarName option` + ); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js index a27cec98d23..cd06f152fa9 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js @@ -3,24 +3,20 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Do not show calendar if calendar name option is "never" +description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); -const cal = { - toString() { return "bogus"; } -}; -const expected = "1976-11-18T15:23:00"; +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00", "custom"], + [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "custom with iso8601 toString"], + [[{ toString() { return "ISO8601"; } }], "1976-11-18T15:23:00", "custom with caps toString"], + [[{ toString() { return "\u0131so8601"; } }], "1976-11-18T15:23:00", "custom with dotless i toString"], +]; -assert.sameValue( - dt.toString({ calendarName: "never" }), - expected, - "Do not show calendar if calendarName = never" -); - -assert.sameValue( - dt.withCalendar(cal).toString({ calendarName: "never" }), - expected, - "Do not show calendar when calendarName = never, even if non-ISO calendar is used" -); +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: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js index b8b741b65f2..982732000e7 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js @@ -14,18 +14,17 @@ info: | features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const datetime1 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const datetime2 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "1976-11-18T15:23:00", "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"], +]; -[ - [datetime1, "2000-05-02T12:34:56.987654321"], - [datetime2, "2000-05-02T12:34:56.987654321[u-ca=custom]"], -].forEach(([datetime, expected]) => { - const explicit = datetime.toString({ calendarName: undefined }); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - // See options-undefined.js for {} -}); +for (const [args, expected, description] of tests) { + const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = datetime.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js new file mode 100644 index 00000000000..6dc5cdea00a --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js @@ -0,0 +1,28 @@ +// 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.protoype.tostring +description: Number of observable 'toString' calls on the calendar for each value of calendarName +features: [Temporal] +---*/ + +let calls; +const customCalendar = { + toString() { + ++calls; + return "custom"; + } +}; +const monthday = new Temporal.PlainMonthDay(5, 2, customCalendar); +[ + ["always", "1972-05-02[u-ca=custom]", 1], + ["auto", "1972-05-02[u-ca=custom]", 1], + ["never", "1972-05-02", 1], + [undefined, "1972-05-02[u-ca=custom]", 1], +].forEach(([calendarName, expectedResult, expectedCalls]) => { + calls = 0; + const result = monthday.toString({ calendarName }); + assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js index 4d1d85b6797..df1d606fda2 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js @@ -1,22 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring +esid: sec-temporal.plainmonthday.prototype.tostring description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ const tests = [ - [[], "1972-05-02[u-ca=iso8601]"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]"], - [[{ toString() { return "iso8601"; } }], "1972-05-02[u-ca=iso8601]"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i + [[], "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] of tests) { +for (const [args, expected, description] of tests) { const monthday = new Temporal.PlainMonthDay(5, 2, ...args); const result = monthday.toString({ calendarName: "always" }); - assert.sameValue(result, expected); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); } diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js index c5f75d787d6..5abf0fa619d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js @@ -1,22 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring +esid: sec-temporal.plainmonthday.prototype.tostring description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ const tests = [ - [[], "05-02"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]"], - [[{ toString() { return "iso8601"; } }], "05-02"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i + [[], "05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "05-02", "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] of tests) { +for (const [args, expected, description] of tests) { const monthday = new Temporal.PlainMonthDay(5, 2, ...args); const result = monthday.toString({ calendarName: "auto" }); - assert.sameValue(result, expected); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); } diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js index 5e702560d86..8ba02abe6b3 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js @@ -15,6 +15,12 @@ features: [Temporal] ---*/ const monthday = new Temporal.PlainMonthDay(5, 2); -for (const calendarName of ["ALWAYS", "sometimes", "other string"]) { - assert.throws(RangeError, () => monthday.toString({ calendarName })); +const invalidValues = ["ALWAYS", "sometimes", "other string", "auto\0"]; + +for (const calendarName of invalidValues) { + assert.throws( + RangeError, + () => monthday.toString({ calendarName }), + `${calendarName} is an invalid value for calendarName option` + ); } diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js index cee35d9bde6..1fbb89abc75 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js @@ -1,22 +1,22 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// 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.protoype.tostring +esid: sec-temporal.plainmonthday.prototype.tostring description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ const tests = [ - [[], "05-02"], - [[{ toString() { return "custom"; } }], "1972-05-02"], - [[{ toString() { return "iso8601"; } }], "05-02"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02"], // dotless i + [[], "05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1972-05-02", "custom"], + [[{ toString() { return "iso8601"; } }], "05-02", "custom with iso8601 toString"], + [[{ toString() { return "ISO8601"; } }], "1972-05-02", "custom with caps toString"], + [[{ toString() { return "\u0131so8601"; } }], "1972-05-02", "custom with dotless i toString"], ]; -for (const [args, expected] of tests) { +for (const [args, expected, description] of tests) { const monthday = new Temporal.PlainMonthDay(5, 2, ...args); const result = monthday.toString({ calendarName: "never" }); - assert.sameValue(result, expected); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); } diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js index b59e15d916c..0b5bfaa756d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js @@ -15,18 +15,16 @@ features: [Temporal] ---*/ const tests = [ - [[], "05-02"], - [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]"], - [[{ toString() { return "iso8601"; } }], "05-02"], - [[{ toString() { return "ISO8601"; } }], "1972-05-02[u-ca=ISO8601]"], - [[{ toString() { return "\u0131so8601"; } }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i + [[], "05-02", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1972-05-02[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "05-02", "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] of tests) { +for (const [args, expected, description] of tests) { const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const explicit = monthday.toString({ calendarName: undefined }); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - const implicit = monthday.toString({}); - assert.sameValue(implicit, expected, "default calendarName option is auto"); + const result = monthday.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js new file mode 100644 index 00000000000..86fda8251fd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js @@ -0,0 +1,28 @@ +// 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.protoype.tostring +description: Number of observable 'toString' calls on the calendar for each value of calendarName +features: [Temporal] +---*/ + +let calls; +const customCalendar = { + toString() { + ++calls; + return "custom"; + } +}; +const yearmonth = new Temporal.PlainYearMonth(2000, 5, customCalendar); +[ + ["always", "2000-05-01[u-ca=custom]", 1], + ["auto", "2000-05-01[u-ca=custom]", 1], + ["never", "2000-05-01", 1], + [undefined, "2000-05-01[u-ca=custom]", 1], +].forEach(([calendarName, expectedResult, expectedCalls]) => { + calls = 0; + const result = yearmonth.toString({ calendarName }); + assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js index be8cc7e93f8..378a056bec6 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js @@ -2,21 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.plainyearmonth.protoype.tostring -description: always value for calendarName option +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); -const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); +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"], +]; -[ - [yearmonth1, "2000-05-01[u-ca=iso8601]"], // fallback day 1 used - [yearmonth2, "2000-05-01[u-ca=custom]"], -].forEach(([yearmonth, expected]) => { +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); const result = yearmonth.toString({ calendarName: "always" }); - assert.sameValue(result, expected, "calendarName is always"); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js index 3aa15bac39b..d4e547d2151 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js @@ -2,21 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.plainyearmonth.protoype.tostring -description: auto value for calendarName option +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); -const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); +const tests = [ + [[], "2000-05", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-01[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05", "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"], +]; -[ - [yearmonth1, "2000-05"], - [yearmonth2, "2000-05-01[u-ca=custom]"], -].forEach(([yearmonth, expected]) => { +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); const result = yearmonth.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, "calendarName is auto"); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js index 23f0ffc9c5c..08e2abb86a1 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js @@ -15,6 +15,12 @@ features: [Temporal] ---*/ const yearmonth = new Temporal.PlainYearMonth(2000, 5); -for (const calendarName of ["ALWAYS", "sometimes", "other string"]) { - assert.throws(RangeError, () => yearmonth.toString({ calendarName })); +const invalidValues = ["ALWAYS", "sometimes", "other string", "auto\0"]; + +for (const calendarName of invalidValues) { + assert.throws( + RangeError, + () => yearmonth.toString({ calendarName }), + `${calendarName} is an invalid value for calendarName option` + ); } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js index e7dd619b9f9..670c0019a7c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js @@ -2,21 +2,21 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.plainyearmonth.protoype.tostring -description: never value for calendarName option +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); -const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); +const tests = [ + [[], "2000-05", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-01", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05", "custom with iso8601 toString"], + [[{ toString() { return "ISO8601"; } }], "2000-05-01", "custom with caps toString"], + [[{ toString() { return "\u0131so8601"; } }], "2000-05-01", "custom with dotless i toString"], +]; -[ - [yearmonth1, "2000-05"], - [yearmonth2, "2000-05-01"], -].forEach(([yearmonth, expected]) => { +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); const result = yearmonth.toString({ calendarName: "never" }); - assert.sameValue(result, expected, "calendarName is never"); -}); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js index 6478995fc14..72e6a04cb58 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js @@ -14,19 +14,17 @@ info: | features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); -const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); +const tests = [ + [[], "2000-05", "built-in ISO"], + [[{ toString() { return "custom"; } }], "2000-05-01[u-ca=custom]", "custom"], + [[{ toString() { return "iso8601"; } }], "2000-05", "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"], +]; -[ - [yearmonth1, "2000-05"], - [yearmonth2, "2000-05-01[u-ca=custom]"], -].forEach(([yearmonth, expected]) => { - const explicit = yearmonth.toString({ calendarName: undefined }); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - const implicit = yearmonth.toString({}); - assert.sameValue(implicit, expected, "default calendarName option is auto"); -}); +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js index d91f9c522b0..67476c0ebda 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.protoype.tostring -description: Should call 'toString' on the calendar once unless calendarName == 'never'. +description: Number of observable 'toString' calls on the calendar for each value of calendarName features: [Temporal] ---*/ @@ -14,15 +14,15 @@ const customCalendar = { return "custom"; } }; -const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", customCalendar); +const date = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", customCalendar); [ - ["always", "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", 1], - ["auto", "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", 1], - ["never", "1970-01-01T01:01:01.987654321+00:00[UTC]", 0], - [undefined, "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", 1], + ["always", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], + ["auto", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], + ["never", "2001-09-09T01:46:40.987654321+00:00[UTC]", 0], + [undefined, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { calls = 0; const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `calendarName = ${calendarName}: expected ${expectedResult}`); - assert.sameValue(calls, expectedCalls, `calendarName = ${calendarName}: expected ${expectedCalls} call(s) to 'toString'`); + assert.sameValue(result, expectedResult, `toString output for calendarName = ${calendarName}`); + assert.sameValue(calls, expectedCalls, `calls to toString for calendarName = ${calendarName}`); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js new file mode 100644 index 00000000000..6deb4cfaa8e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js @@ -0,0 +1,22 @@ +// 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 "always", the calendar ID should be included. +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: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js new file mode 100644 index 00000000000..fef22aebacb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js @@ -0,0 +1,22 @@ +// 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 "auto", "iso8601" should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "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]", "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: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js index 0b4967d73cf..51a7360c8db 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js @@ -14,5 +14,13 @@ info: | features: [Temporal] ---*/ -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_64_321n, "UTC"); -assert.throws(RangeError, () => datetime.toString({ calendarName: "other string" })); +const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); +const invalidValues = ["ALWAYS", "sometimes", "other string", "auto\0"]; + +for (const calendarName of invalidValues) { + assert.throws( + RangeError, + () => datetime.toString({ calendarName }), + `${calendarName} is an invalid value for calendarName option` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js new file mode 100644 index 00000000000..621c8a8c8ed --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js @@ -0,0 +1,22 @@ +// 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 "never", the calendar ID should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], + [[{ toString() { return "custom"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom"], + [[{ toString() { return "iso8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 toString"], + [[{ toString() { return "ISO8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with caps toString"], + [[{ toString() { return "\u0131so8601"; } }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "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: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js index 207d1df30f8..509b56fcbde 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js @@ -14,19 +14,17 @@ info: | features: [Temporal] ---*/ -const calendar = { - toString() { return "custom"; } -}; -const datetime1 = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); -const datetime2 = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); - -[ - [datetime1, "2001-09-09T01:46:40.987654321+00:00[UTC]"], - [datetime2, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]"], -].forEach(([datetime, expected]) => { - const explicit = datetime.toString({ calendarName: undefined }); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - // See options-undefined.js for {} -}); +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "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]", "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 datetime = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = datetime.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/staging/Temporal/ZonedDateTime/old/toString.js b/test/staging/Temporal/ZonedDateTime/old/toString.js index 8137518a228..0f86a4cdcd3 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toString.js +++ b/test/staging/Temporal/ZonedDateTime/old/toString.js @@ -11,25 +11,6 @@ features: [Temporal] var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); var fakeGregorian = { toString() { return "gregory" }}; -// shows only non-ISO calendar if calendarName = auto -assert.sameValue(zdt1.toString({ calendarName: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); -assert.sameValue(zdt1.withCalendar(fakeGregorian).toString({ calendarName: "auto" }), "1976-11-18T15:23:00+00:00[UTC][u-ca=gregory]"); - -// shows ISO calendar if calendarName = always -assert.sameValue(zdt1.toString({ calendarName: "always" }), "1976-11-18T15:23:00+00:00[UTC][u-ca=iso8601]"); - -// omits non-ISO calendar if calendarName = never -assert.sameValue(zdt1.withCalendar(fakeGregorian).toString({ calendarName: "never" }), "1976-11-18T15:23:00+00:00[UTC]"); - -// throws on invalid calendar -[ - "ALWAYS", - "sometimes", - false, -].forEach(calendarName => { - assert.throws(RangeError, () => zdt1.toString({ calendarName })); -}); - // shows time zone if timeZoneName = auto assert.sameValue(zdt1.toString({ timeZoneName: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); From 3d0f112afec108e4515bb6384e92e8f0b4c63f04 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 18:11:35 -0700 Subject: [PATCH 08/11] Temporal: Add tests for calendarName: "critical" option See https://github.com/tc39/proposal-temporal/pull/2397 This normative change adds a new accepted value for the calendarName option in various toString() methods. --- .../prototype/toString/calendar-tostring.js | 1 + .../toString/calendarname-critical.js | 24 +++++++++++++++++++ .../toString/calendarname-invalid-string.js | 2 +- .../toString/calendarname-undefined.js | 2 +- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/calendar-tostring.js | 1 + .../toString/calendarname-critical.js | 24 +++++++++++++++++++ .../toString/calendarname-invalid-string.js | 2 +- .../toString/calendarname-undefined.js | 2 +- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/calendar-tostring.js | 1 + .../toString/calendarname-critical.js | 24 +++++++++++++++++++ .../toString/calendarname-invalid-string.js | 2 +- .../toString/calendarname-undefined.js | 2 +- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/calendar-tostring.js | 1 + .../toString/calendarname-critical.js | 24 +++++++++++++++++++ .../toString/calendarname-invalid-string.js | 2 +- .../toString/calendarname-undefined.js | 2 +- .../toString/calendarname-wrong-type.js | 2 +- .../prototype/toString/calendar-tostring.js | 1 + .../toString/calendarname-critical.js | 24 +++++++++++++++++++ .../toString/calendarname-invalid-string.js | 2 +- .../toString/calendarname-undefined.js | 2 +- .../toString/calendarname-wrong-type.js | 2 +- 25 files changed, 140 insertions(+), 15 deletions(-) create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js index 38f5573938d..7dd8ee3a49b 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js @@ -18,6 +18,7 @@ const date = new Temporal.PlainDate(2000, 5, 2, customCalendar); [ ["always", "2000-05-02[u-ca=custom]", 1], ["auto", "2000-05-02[u-ca=custom]", 1], + ["critical", "2000-05-02[!u-ca=custom]", 1], ["never", "2000-05-02", 0], [undefined, "2000-05-02[u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..1a2dee05303 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js @@ -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`); +} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js index fc476e02876..0d5900f944f 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindate.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js index fafbd11fd88..b6b0c4f6852 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindate.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js index 2a621ea31f5..c14aa25a9c5 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindate.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). includes: [compareArray.js, temporalHelpers.js] diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js index 0dc825c8fac..14538ab4cb1 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js @@ -18,6 +18,7 @@ const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, c [ ["always", "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], ["auto", "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], + ["critical", "2000-05-02T12:34:56.987654321[!u-ca=custom]", 1], ["never", "2000-05-02T12:34:56.987654321", 0], [undefined, "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..69bbe1add4c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js @@ -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`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js index 6b880f0d3da..71c6cc8d530 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js index 982732000e7..800fac39da5 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js index 171546b2120..a452be5bdba 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plaindatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). includes: [compareArray.js, temporalHelpers.js] diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js index 6dc5cdea00a..1df2ef8da2e 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js @@ -18,6 +18,7 @@ const monthday = new Temporal.PlainMonthDay(5, 2, customCalendar); [ ["always", "1972-05-02[u-ca=custom]", 1], ["auto", "1972-05-02[u-ca=custom]", 1], + ["critical", "1972-05-02[!u-ca=custom]", 1], ["never", "1972-05-02", 1], [undefined, "1972-05-02[u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..f49b6f89ffb --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js @@ -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`); +} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js index 8ba02abe6b3..363c077a81a 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainmonthday.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js index 0b5bfaa756d..8fc2cde338d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainmonthday.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js index 260c7d3c877..39328d7e574 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainmonthday.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). includes: [compareArray.js, temporalHelpers.js] diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js index 86fda8251fd..3eec13d7791 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js @@ -18,6 +18,7 @@ const yearmonth = new Temporal.PlainYearMonth(2000, 5, customCalendar); [ ["always", "2000-05-01[u-ca=custom]", 1], ["auto", "2000-05-01[u-ca=custom]", 1], + ["critical", "2000-05-01[!u-ca=custom]", 1], ["never", "2000-05-01", 1], [undefined, "2000-05-01[u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..85e50d262c6 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js @@ -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`); +} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js index 08e2abb86a1..8de67c2b1f6 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainyearmonth.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js index 72e6a04cb58..23592c7d548 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainyearmonth.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js index 301b62703a9..4ad85fe1df5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.plainyearmonth.protoype.tostring step 4: 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). includes: [compareArray.js, temporalHelpers.js] diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js index 67476c0ebda..8d88548e442 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js @@ -18,6 +18,7 @@ const date = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", custo [ ["always", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], ["auto", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], + ["critical", "2001-09-09T01:46:40.987654321+00:00[UTC][!u-ca=custom]", 1], ["never", "2001-09-09T01:46:40.987654321+00:00[UTC]", 0], [undefined, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], ].forEach(([calendarName, expectedResult, expectedCalls]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..cd1742d82df --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js @@ -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`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js index 51a7360c8db..38b6e158cac 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js index 509b56fcbde..3464bc79c21 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js index 5f1e7e73a9a..14e15ecd2a6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowcalendaroption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « String », « *"auto"*, *"always"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 6: 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). includes: [compareArray.js, temporalHelpers.js] From 07582cd3b7a0cc8caa2b7d29301306836bd8f303 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 18:27:57 -0700 Subject: [PATCH 09/11] 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. --- .../prototype/toString/timezonename-auto.js | 23 +++++++++++++++++++ .../toString/timezonename-invalid-string.js | 10 +++++++- .../prototype/toString/timezonename-never.js | 23 +++++++++++++++++++ .../toString/timezonename-undefined.js | 2 +- .../Temporal/ZonedDateTime/old/toString.js | 6 ----- 5 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js new file mode 100644 index 00000000000..10e97af7086 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js @@ -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`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js index 94067c25900..dbf82a82102 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js @@ -15,4 +15,12 @@ features: [Temporal] ---*/ const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_64_321n, "UTC"); -assert.throws(RangeError, () => datetime.toString({ timeZoneName: "other string" })); +const invalidValues = ["NEVER", "sometimes", "other string", "auto\0"]; + +for (const timeZoneName of invalidValues) { + assert.throws( + RangeError, + () => datetime.toString({ timeZoneName }), + `${timeZoneName} is an invalid value for timeZoneName option` + ); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js new file mode 100644 index 00000000000..632dff2ccb2 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js @@ -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`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js index 7973c987d74..3e86590b67a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js @@ -19,4 +19,4 @@ const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); const explicit = datetime.toString({ timeZoneName: undefined }); assert.sameValue(explicit, "2001-09-09T01:46:40.987654321+00:00[UTC]", "default timeZoneName option is auto"); -// See options-undefined.js for {} +// See options-object.js for {} and options-undefined.js for absent diff --git a/test/staging/Temporal/ZonedDateTime/old/toString.js b/test/staging/Temporal/ZonedDateTime/old/toString.js index 0f86a4cdcd3..7703f05e7b9 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toString.js +++ b/test/staging/Temporal/ZonedDateTime/old/toString.js @@ -11,12 +11,6 @@ features: [Temporal] var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); var fakeGregorian = { toString() { return "gregory" }}; -// shows time zone if timeZoneName = auto -assert.sameValue(zdt1.toString({ timeZoneName: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); - -// omits time zone if timeZoneName = never -assert.sameValue(zdt1.toString({ timeZoneName: "never" }), "1976-11-18T15:23:00+00:00"); - // shows offset if offset = auto assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); From 3f71a0269305db5cefb4e63d54c7bb6c4c1f3036 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 18:28:31 -0700 Subject: [PATCH 10/11] Temporal: Add tests for ZDT#toString timeZoneName: "critical" option See https://github.com/tc39/proposal-temporal/pull/2397 This normative change adds a new accepted value for the timeZoneName option in ZonedDateTime.prototype.toString(). --- .../toString/timezonename-critical.js | 25 +++++++++++++++++++ .../toString/timezonename-invalid-string.js | 2 +- .../toString/timezonename-undefined.js | 2 +- .../toString/timezonename-wrong-type.js | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js new file mode 100644 index 00000000000..05698e8272f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js @@ -0,0 +1,25 @@ +// 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 and prefixed + with "!" +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: "critical" }); + assert.sameValue(result, expected, `${description} time zone for timeZoneName = critical`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js index dbf82a82102..2df531c727e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-invalid-string.js @@ -8,7 +8,7 @@ info: | sec-getoption step 10: 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. sec-temporal-toshowtimezonenameoption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « String », « *"auto"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « *"string"* », « *"auto"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 7: 7. Let _showTimeZone_ be ? ToShowTimeZoneNameOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js index 3e86590b67a..15430dfe11a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-undefined.js @@ -8,7 +8,7 @@ info: | sec-getoption step 3: 3. If _value_ is *undefined*, return _fallback_. sec-temporal-toshowtimezonenameoption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « String », « *"auto"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « *"string"* », « *"auto"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 7: 7. Let _showTimeZone_ be ? ToShowTimeZoneNameOption(_options_). features: [Temporal] diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-wrong-type.js index e83112b28dd..9c682085f3f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-wrong-type.js @@ -8,7 +8,7 @@ info: | sec-getoption step 9.a: a. Set _value_ to ? ToString(_value_). sec-temporal-toshowtimezonenameoption step 1: - 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « String », « *"auto"*, *"never"* », *"auto"*). + 1. Return ? GetOption(_normalizedOptions_, *"timeZoneName"*, « *"string"* », « *"auto"*, *"never"*, *"critical"* », *"auto"*). sec-temporal.zoneddatetime.protoype.tostring step 7: 7. Let _showTimeZone_ be ? ToShowTimeZoneNameOption(_options_). includes: [compareArray.js, temporalHelpers.js] From 576d01e6d2ed279a66e4c226765841dde3d6f2a7 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 7 Oct 2022 18:43:43 -0700 Subject: [PATCH 11/11] Temporal: Test that the offset option has the last word in ZDT.from() The programmer always gets the last word over how the string is interpreted, since otherwise it's not possible to make any guarantees about the offset option. (This is the "out-of-band" mechanism mentioned in the IETF draft.) Add a test for this. --- .../from/offset-overrides-critical-flag.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/offset-overrides-critical-flag.js diff --git a/test/built-ins/Temporal/ZonedDateTime/from/offset-overrides-critical-flag.js b/test/built-ins/Temporal/ZonedDateTime/from/offset-overrides-critical-flag.js new file mode 100644 index 00000000000..b303b29d0be --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/offset-overrides-critical-flag.js @@ -0,0 +1,30 @@ +// 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.from +description: > + The offset option always overrides the critical flag in a time zone annotation +features: [Temporal] +---*/ + +const useResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "use" }); +assert.sameValue( + useResult.epochNanoseconds, + 1665193020000000000n, + "exact time is unchanged with offset = use, despite critical flag" +); + +const ignoreResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "ignore" }); +assert.sameValue( + ignoreResult.epochNanoseconds, + 1665167820000000000n, + "wall time is unchanged with offset = ignore, despite critical flag" +); + +const preferResult = Temporal.ZonedDateTime.from("2022-10-07T18:37-07:00[!UTC]", { offset: "prefer" }); +assert.sameValue( + useResult.epochNanoseconds, + 1665193020000000000n, + "offset is recalculated with offset = prefer, despite critical flag" +);