diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..e5d004cb0b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.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.calendar.prototype.dateadd +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateAdd(arg, new Temporal.Duration()), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js index 260ab70500..8e1513b841 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.dateAdd(arg, new Temporal.Duration()); }, + () => instance.dateAdd(arg, new Temporal.Duration()), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..773fe54515 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.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.dateuntil +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), + "reject minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js index effb46112b..b6c4ea0415 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js @@ -9,16 +9,23 @@ features: [Temporal] const calendar = new Temporal.Calendar("iso8601"); const date = new Temporal.PlainDate(2000, 5, 2); -const bad = "-000000-03-14"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; -assert.throws( - RangeError, - () => calendar.dateUntil(bad, date), - "cannot use minus zero as extended date (first argument)" -); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => calendar.dateUntil(arg, date), + "cannot use minus zero as extended date (first argument)" + ); -assert.throws( - RangeError, - () => calendar.dateUntil(date, bad), - "cannot use minus zero as extended date (second argument)" -); + assert.throws( + RangeError, + () => calendar.dateUntil(date, arg), + "cannot use minus zero as extended date (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..cf64d454b0 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.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.calendar.prototype.day +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.day(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js index 555a3f62c0..91daa87476 100644 --- a/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.day(arg); }, + () => instance.day(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..871fd74463 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.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.calendar.prototype.dayofweek +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfWeek(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js index 18ab7a6827..0d887a3978 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.dayOfWeek(arg); }, + () => instance.dayOfWeek(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..7335b890c4 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.dayofyear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.dayOfYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js index e31b214116..6fec20e469 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.dayOfYear(arg); }, + () => instance.dayOfYear(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..1f273d6d43 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.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.calendar.prototype.daysinmonth +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInMonth(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js index c2c6204ed6..d4a5d70149 100644 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.daysInMonth(arg); }, + () => instance.daysInMonth(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..0c27c02bfa --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.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.calendar.prototype.daysinweek +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInWeek(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js index b852ef7814..67caad3a5e 100644 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.daysInWeek(arg); }, + () => instance.daysInWeek(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..62a9e6d18e --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.daysinyear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.daysInYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js index 4c226015b2..9bb94a19d3 100644 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.daysInYear(arg); }, + () => instance.daysInYear(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..4a5b92aea8 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.inleapyear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.inLeapYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js index 8aeb7c2a76..f96bac46a4 100644 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.inLeapYear(arg); }, + () => instance.inLeapYear(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..1d41054f50 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.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.calendar.prototype.month +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.month(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js index f42751175a..b54957b1c1 100644 --- a/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.month(arg); }, + () => instance.month(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..1f385c2203 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.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.calendar.prototype.monthcode +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthCode(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js index fc81c5348e..5ad4d0dde7 100644 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.monthCode(arg); }, + () => instance.monthCode(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..1d4af99f7b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.monthsinyear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.monthsInYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js index 0451a66559..6e3e0b960e 100644 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.monthsInYear(arg); }, + () => instance.monthsInYear(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..5f8dcccc98 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.weekofyear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.weekOfYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js index 44eeabb321..0a2cdc66e2 100644 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.weekOfYear(arg); }, + () => instance.weekOfYear(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..6f68cf3e84 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.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.calendar.prototype.year +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.year(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js index 6221b7db92..dc7f72566a 100644 --- a/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js +++ b/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.year(arg); }, + () => instance.year(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/Duration/compare/timezone-string-year-zero.js b/test/built-ins/Temporal/Duration/compare/timezone-string-year-zero.js new file mode 100644 index 0000000000..0c8d50f0e2 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/timezone-string-year-zero.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.duration.compare +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Duration/prototype/add/timezone-string-year-zero.js b/test/built-ins/Temporal/Duration/prototype/add/timezone-string-year-zero.js new file mode 100644 index 0000000000..2f09d730ba --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/timezone-string-year-zero.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.duration.prototype.add +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Duration(1); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/timezone-string-year-zero.js b/test/built-ins/Temporal/Duration/prototype/round/timezone-string-year-zero.js new file mode 100644 index 0000000000..290099ebed --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/timezone-string-year-zero.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.duration.prototype.round +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Duration(1); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/timezone-string-year-zero.js b/test/built-ins/Temporal/Duration/prototype/subtract/timezone-string-year-zero.js new file mode 100644 index 0000000000..251016b432 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/timezone-string-year-zero.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.duration.prototype.subtract +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Duration(1); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/timezone-string-year-zero.js b/test/built-ins/Temporal/Duration/prototype/total/timezone-string-year-zero.js new file mode 100644 index 0000000000..223a510ca9 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/timezone-string-year-zero.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.duration.prototype.total +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Duration(1); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Instant/compare/year-zero.js b/test/built-ins/Temporal/Instant/compare/year-zero.js index e6bb684d43..23293adff1 100644 --- a/test/built-ins/Temporal/Instant/compare/year-zero.js +++ b/test/built-ins/Temporal/Instant/compare/year-zero.js @@ -8,12 +8,18 @@ features: [Temporal] ---*/ const instance = new Temporal.Instant(0n); -const bad = '-000000-03-30T00:45Z'; +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", +]; -assert.throws(RangeError, - () => Temporal.Instant.compare(bad, instance), - "minus zero is invalid extended year (first argument)"); -assert.throws(RangeError, - () => Temporal.Instant.compare(instance, bad), - "minus zero is invalid extended year (second argument)" -); +invalidStrings.forEach((arg) => { + assert.throws(RangeError, + () => Temporal.Instant.compare(arg, instance), + "minus zero is invalid extended year (first argument)"); + assert.throws(RangeError, + () => Temporal.Instant.compare(instance, arg), + "minus zero is invalid extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/Instant/from/year-zero.js b/test/built-ins/Temporal/Instant/from/year-zero.js index b21396b894..5d1ad4a84f 100644 --- a/test/built-ins/Temporal/Instant/from/year-zero.js +++ b/test/built-ins/Temporal/Instant/from/year-zero.js @@ -4,19 +4,19 @@ /*--- esid: sec-temporal.instant.from description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-03-31T00:45Z", - "-000000-03-31T01:45+01:00", - "-000000-03-31T01:45:00+01:00[UTC]" + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", ]; -invalidStrings.forEach((str) => { +invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => Temporal.Instant.from(str), + () => Temporal.Instant.from(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/year-zero.js b/test/built-ins/Temporal/Instant/prototype/equals/year-zero.js index d2932d2888..d568c70c3b 100644 --- a/test/built-ins/Temporal/Instant/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/Instant/prototype/equals/year-zero.js @@ -4,19 +4,19 @@ /*--- esid: sec-temporal.instant.prototype.equals description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+01:00[UTC]" + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", ]; const instance = new Temporal.Instant(0n); -invalidStrings.forEach((str) => { +invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => instance.equals(str), + () => instance.equals(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/Instant/prototype/since/year-zero.js b/test/built-ins/Temporal/Instant/prototype/since/year-zero.js index 38bf10fd67..e8f765c689 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/Instant/prototype/since/year-zero.js @@ -4,19 +4,19 @@ /*--- esid: sec-temporal.instant.prototype.since description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+01:00[UTC]" + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", ]; const instance = new Temporal.Instant(0n); -invalidStrings.forEach((str) => { +invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => instance.since(str), + () => instance.since(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-year-zero.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-year-zero.js new file mode 100644 index 0000000000..c04a611c07 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-year-zero.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.prototype.tostring +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toString({ timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toString({ timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..841a1bcb3d --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.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.prototype.tozoneddatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-year-zero.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-year-zero.js new file mode 100644 index 0000000000..a8a397ada4 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-year-zero.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.prototype.tozoneddatetimeiso +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTimeISO(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toZonedDateTimeISO({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/year-zero.js b/test/built-ins/Temporal/Instant/prototype/until/year-zero.js index 28953c09e5..641cf7f3d6 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/Instant/prototype/until/year-zero.js @@ -4,19 +4,19 @@ /*--- esid: sec-temporal.instant.prototype.until description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+01:00[UTC]" + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", ]; const instance = new Temporal.Instant(0n); -invalidStrings.forEach((str) => { +invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => instance.until(str), + () => instance.until(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js new file mode 100644 index 0000000000..71bb7a11a7 --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.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.now.plaindate +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDate("iso8601", timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.plainDate("iso8601", { timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.js new file mode 100644 index 0000000000..5a0c755aa7 --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-year-zero.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.now.plaindateiso +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateISO(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.plainDateISO({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..32c6a023c7 --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.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.now.plaindatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTime("iso8601", timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.plainDateTime("iso8601", { timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-year-zero.js new file mode 100644 index 0000000000..48501a4b07 --- /dev/null +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-year-zero.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.now.plaindatetimeiso +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainDateTimeISO(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.plainDateTimeISO({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-year-zero.js new file mode 100644 index 0000000000..a9770de6fd --- /dev/null +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-year-zero.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.now.plaintimeiso +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.plainTimeISO(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.plainTimeISO({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..e27b3f1730 --- /dev/null +++ b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.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.now.zoneddatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTime("iso8601", timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTime("iso8601", { timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-year-zero.js new file mode 100644 index 0000000000..6417c0a787 --- /dev/null +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-year-zero.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.now.zoneddatetimeiso +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTimeISO(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.Now.zonedDateTimeISO({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..d99de36cdf --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), + "reject minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/year-zero.js b/test/built-ins/Temporal/PlainDate/compare/year-zero.js index 75f79cf98e..9bb6812aff 100644 --- a/test/built-ins/Temporal/PlainDate/compare/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/compare/year-zero.js @@ -8,14 +8,21 @@ features: [Temporal] ---*/ const instance = new Temporal.PlainDate(2000, 5, 2); -const bad = "-000000-08-24"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; -assert.throws(RangeError, - () => Temporal.PlainDate.compare(bad, instance), - "Minus zero is an invalid extended year (first argument)" -); +invalidStrings.forEach((arg) => { + assert.throws(RangeError, + () => Temporal.PlainDate.compare(arg, instance), + "Minus zero is an invalid extended year (first argument)" + ); -assert.throws(RangeError, - () => Temporal.PlainDate.compare(instance, bad), - "Minus zero is an invalid extended year (second argument)" -); + assert.throws(RangeError, + () => Temporal.PlainDate.compare(instance, arg), + "Minus zero is an invalid extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..daafcd37aa --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-year-zero.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.from +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDate.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/from/year-zero.js b/test/built-ins/Temporal/PlainDate/from/year-zero.js index 0e000677f2..16c6cd9c28 100644 --- a/test/built-ins/Temporal/PlainDate/from/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/from/year-zero.js @@ -4,14 +4,20 @@ /*--- esid: sec-temporal.plaindate.from description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { Temporal.PlainDate.from(arg); }, + () => Temporal.PlainDate.from(arg), "reject minus zero as extended year" -); - + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..6263cc5a70 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-year-zero.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.equals +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/equals/year-zero.js index 486a5da1ac..674d60a471 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.equals(arg); }, + () => instance.equals(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..10fe06753d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-year-zero.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.since +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/since/year-zero.js index 9f83cc531c..92fa4f294c 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.since(arg); }, + () => instance.since(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/year-zero.js index d02df20145..12cc1f466b 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDate(2000, 5, 2); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..62e499eb4f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toZonedDateTime({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js index 018ffdb90d..20420664aa 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDate(2000, 5, 2); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..6ed6fb9e30 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-year-zero.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.until +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/until/year-zero.js index 28a7861727..819913d022 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.until(arg); }, + () => instance.until(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..b50886514d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), + "reject minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js b/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js index f32f6cb0e3..d71f6f0771 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js @@ -8,14 +8,21 @@ features: [Temporal] ---*/ const ok = new Temporal.PlainDateTime(2000, 5, 2, 15); -const bad = "-000000-12-07T03:24:30"; +const invalidStrings = [ + "-000000-12-07", + "-000000-12-07T03:24:30", + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", +]; -assert.throws(RangeError, - () => Temporal.PlainDateTime.compare(bad,ok), - "Cannot use minus zero as extended year (first argument)" -); +invalidStrings.forEach((arg) => { + assert.throws(RangeError, + () => Temporal.PlainDateTime.compare(arg, ok), + "Cannot use minus zero as extended year (first argument)" + ); -assert.throws(RangeError, - () => Temporal.PlainDateTime.compare(ok, bad), - "Cannot use minus zero as extended year (second argument)" -); + assert.throws(RangeError, + () => Temporal.PlainDateTime.compare(ok, arg), + "Cannot use minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..833ed2f08d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainDateTime.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/year-zero.js b/test/built-ins/Temporal/PlainDateTime/from/year-zero.js index 7f21302a3b..f40d3345a4 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/from/year-zero.js @@ -8,13 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; + invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { Temporal.PlainDateTime.from(arg); }, + () => Temporal.PlainDateTime.from(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..2ada66e34e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[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 minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js index 175c2d7016..6eb6fd5c27 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js @@ -8,14 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { instance.equals(arg); }, + () => instance.equals(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..26dd4d767b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[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 minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js index e7b6146a57..bc376c2353 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js @@ -8,14 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { instance.since(arg); }, + () => instance.since(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..79caa639eb --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-year-zero.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.tozoneddatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toZonedDateTime({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..3773980497 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[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 minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js index 028410a06d..dd7ac76c96 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js @@ -8,14 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { instance.until(arg); }, + () => instance.until(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..bb85c7bec1 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.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.withplaindate +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[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 minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js index 392a7ec2c0..b6fffe30e4 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.withPlainDate(arg); }, + () => instance.withPlainDate(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero.js index 2e9a875e52..19734655f1 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..c71ce5ee2d --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/year-zero.js b/test/built-ins/Temporal/PlainMonthDay/from/year-zero.js index 347dba0928..782debd933 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/year-zero.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/year-zero.js @@ -8,15 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-08", - "-000000-08-24", - "-000000-08-24T15:43:27", - "-000000-08-24T15:43:27+01:00[UTC]" + "-000000-08-24", + "-000000-08-24T15:43:27", + "-000000-08-24T15:43:27+01:00", + "-000000-08-24T15:43:27+00:00[UTC]", ]; + invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { Temporal.PlainMonthDay.from(arg); }, + () => Temporal.PlainMonthDay.from(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..b50c75421c --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainMonthDay(5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js index f420f38b46..155b4a114a 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js @@ -8,10 +8,10 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-08", - "-000000-08-24", - "-000000-08-24T15:43:27", - "-000000-08-24T15:43:27+01:00[UTC]" + "-000000-08-24", + "-000000-08-24T15:43:27", + "-000000-08-24T15:43:27+01:00", + "-000000-08-24T15:43:27+00:00[UTC]", ]; const instance = new Temporal.PlainMonthDay(5, 2); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainTime/compare/year-zero.js b/test/built-ins/Temporal/PlainTime/compare/year-zero.js index 470b42fda1..ca3d4b5e47 100644 --- a/test/built-ins/Temporal/PlainTime/compare/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/compare/year-zero.js @@ -8,16 +8,22 @@ features: [Temporal] ---*/ const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -const bad = "-000000-12-07T03:24:30"; +const invalidStrings = [ + "-000000-12-07T03:24:30", + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", +]; -assert.throws( - RangeError, - () => Temporal.PlainTime.compare(bad, time), - "Cannot use minus zero as extended year (first argument)" -); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(arg, time), + "Cannot use minus zero as extended year (first argument)" + ); -assert.throws( - RangeError, - () => Temporal.PlainTime.compare(time, bad), - "Cannot use minus zero as extended year (second argument)" -); + assert.throws( + RangeError, + () => Temporal.PlainTime.compare(time, arg), + "Cannot use minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/from/year-zero.js b/test/built-ins/Temporal/PlainTime/from/year-zero.js index 1803d2df10..39b849c69b 100644 --- a/test/built-ins/Temporal/PlainTime/from/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/from/year-zero.js @@ -9,12 +9,14 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; + invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { Temporal.PlainTime.from(arg); }, + () => Temporal.PlainTime.from(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js index c531c931ad..56ea599d8a 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js index d28b618175..e2261ea82c 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..802381765c --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.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.plaintime.prototype.toplaindatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js index 481f20b37a..e08a6d0305 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.toPlainDateTime(arg); }, + () => instance.toPlainDateTime(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..fb6c3eca80 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.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.plaintime.prototype.tozoneddatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[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 minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.js new file mode 100644 index 0000000000..80a06780bc --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.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.tozoneddatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainTime(); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js index 54112f1563..6fb496ea92 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); }, + () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js index 3effb46fc4..ff561458ad 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js @@ -9,7 +9,8 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..f436289f12 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg), + "reject minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js index 5d1a6cd03e..f4de105c40 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js @@ -8,16 +8,24 @@ features: [Temporal] ---*/ const ok = new Temporal.PlainYearMonth(2000, 5); -const bad = "-000000-06"; +const invalidStrings = [ + "-000000-06", + "-000000-06-24", + "-000000-06-24T15:43:27", + "-000000-06-24T15:43:27+01:00", + "-000000-06-24T15:43:27+00:00[UTC]", +]; -assert.throws( - RangeError, - () => Temporal.PlainYearMonth.compare(bad, ok), - "Cannot use minus zero as extended year (first argument)" -); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(arg, ok), + "Cannot use minus zero as extended year (first argument)" + ); -assert.throws( - RangeError, - () => Temporal.PlainYearMonth.compare(ok, bad), - "Cannot use minus zero as extended year (second argument)" -); + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(ok, arg), + "Cannot use minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..60b0d94490 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js index 1d8c7b3af7..930951a8da 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js @@ -8,15 +8,17 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - '-000000-06', - '-000000-06-24', - '-000000-06-24T15:43:27', - '-000000-06-24T15:43:27+01:00[UTC]' + "-000000-06", + "-000000-06-24", + "-000000-06-24T15:43:27", + "-000000-06-24T15:43:27+01:00", + "-000000-06-24T15:43:27+00:00[UTC]", ]; + invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { Temporal.PlainYearMonth.from(arg); }, + () => Temporal.PlainYearMonth.from(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..b5e0c3045c --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/year-zero.js index 9ab97736fd..11c10168d7 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/year-zero.js @@ -3,15 +3,16 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.equals -description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - '-000000-06', - '-000000-06-24', - '-000000-06-24T15:43:27', - '-000000-06-24T15:43:27+01:00[UTC]' + "-000000-06", + "-000000-06-24", + "-000000-06-24T15:43:27", + "-000000-06-24T15:43:27+01:00", + "-000000-06-24T15:43:27+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..c4701a3aeb --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js index e1b9610383..7bb5b9611c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js @@ -3,15 +3,16 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.since -description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - '-000000-06', - '-000000-06-24', - '-000000-06-24T15:43:27', - '-000000-06-24T15:43:27+01:00[UTC]' + "-000000-06", + "-000000-06-24", + "-000000-06-24T15:43:27", + "-000000-06-24T15:43:27+01:00", + "-000000-06-24T15:43:27+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..d8a718b0ad --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.PlainYearMonth(2000, 5); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js index b2f534aeff..2326993bbc 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js @@ -3,15 +3,16 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.until -description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - '-000000-06', - '-000000-06-24', - '-000000-06-24T15:43:27', - '-000000-06-24T15:43:27+01:00[UTC]' + "-000000-06", + "-000000-06-24", + "-000000-06-24T15:43:27", + "-000000-06-24T15:43:27+01:00", + "-000000-06-24T15:43:27+00:00[UTC]", ]; const instance = new Temporal.PlainYearMonth(2000, 5); invalidStrings.forEach((arg) => { diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.js new file mode 100644 index 0000000000..59940a4faa --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.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.timezone.from +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.TimeZone.from(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.TimeZone.from({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..f282e30534 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getInstantFor(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js index dfa1f9121d..d7ed91a2bf 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js @@ -8,14 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.TimeZone("UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { instance.getInstantFor(arg); }, + () => instance.getInstantFor(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js index f93af18150..3874a284fb 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js @@ -4,10 +4,19 @@ /*--- esid: sec-temporal.timezone.prototype.getnexttransition description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", +]; const instance = new Temporal.TimeZone("UTC"); - -let str = "-000000-01-01T00:00"; -assert.throws(RangeError, () => instance.getNextTransition(str), "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getNextTransition(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js index 91275f9836..2af428da65 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js @@ -4,10 +4,19 @@ /*--- esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", +]; const instance = new Temporal.TimeZone("UTC"); - -let str = "-000000-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetNanosecondsFor(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js index 3840a51ff8..a093331990 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js @@ -4,10 +4,19 @@ /*--- esid: sec-temporal.timezone.prototype.getoffsetstringfor description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", +]; const instance = new Temporal.TimeZone("UTC"); - -let str = "-000000-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetStringFor(str), "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getOffsetStringFor(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js index d15162a5e7..aa2b02626e 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js @@ -4,19 +4,19 @@ /*--- esid: sec-temporal.timezone.prototype.getplaindatetimefor description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+01:00[UTC]" + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", ]; const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((str) => { +invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => instance.getPlainDateTimeFor(str), + () => instance.getPlainDateTimeFor(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..44bb062dcd --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPossibleInstantsFor(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js index e6efaf6004..0db44c1869 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js @@ -8,14 +8,16 @@ features: [Temporal, arrow-function] ---*/ const invalidStrings = [ + "-000000-12-07", "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; const instance = new Temporal.TimeZone("UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, - () => { instance.getPossibleInstantsFor(arg); }, + () => instance.getPossibleInstantsFor(arg), "reject minus zero as extended year" ); }); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js index 5586567210..07b1e7248f 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js @@ -4,10 +4,19 @@ /*--- esid: sec-temporal.timezone.prototype.getprevioustransition description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+00:00[UTC]", +]; const instance = new Temporal.TimeZone("UTC"); - -let str = "-000000-01-01T00:00"; -assert.throws(RangeError, () => instance.getPreviousTransition(str), "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.getPreviousTransition(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..26a1253b18 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(arg, datetime), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, arg), + "reject minus zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/timezone-string-year-zero.js new file mode 100644 index 0000000000..7f170bfe7e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/timezone-string-year-zero.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.compare +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, datetime), + "reject minus zero as extended year (first argument)" + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, { year: 2020, month: 5, day: 2, timeZone }), + "reject minus zero as extended year (second argument)" + ); + + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }, datetime), + "reject minus zero as extended year (nested property, first argument)" + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.compare(datetime, { year: 2020, month: 5, day: 2, timeZone: { timeZone } }), + "reject minus zero as extended year (nested property, second argument)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js index 314b364b42..82ec45e13b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js @@ -8,13 +8,19 @@ features: [Temporal] ---*/ const instance = new Temporal.ZonedDateTime(0n, "UTC"); -const bad = "-000000-08-19T17:30Z"; +const invalidStrings = [ + "-0000000-01-01T00:02Z[UTC]", + "-0000000-01-01T00:02+00:00[UTC]", + "-0000000-01-01T00:02:00.000000000+00:00[UTC]", +]; -assert.throws(RangeError, - () => Temporal.ZonedDateTime.compare(bad, instance), - "cannot use negative zero as extended year (first argument)" -); -assert.throws(RangeError, - () => Temporal.ZonedDateTime.compare(instance, bad), - "cannot use negative zero as extended year (second argument)" -); +invalidStrings.forEach((arg) => { + assert.throws(RangeError, + () => Temporal.ZonedDateTime.compare(arg, instance), + "cannot use negative zero as extended year (first argument)" + ); + assert.throws(RangeError, + () => Temporal.ZonedDateTime.compare(instance, arg), + "cannot use negative zero as extended year (second argument)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..ffabba823f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; + +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-year-zero.js new file mode 100644 index 0000000000..0065848f01 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/timezone-string-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js index da7638028a..727200f859 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js @@ -4,9 +4,19 @@ /*--- esid: sec-temporal.zoneddatetime.from description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ -const str = "-0000000-01-01T00:02:00.000000000+00:00[UTC]"; +const invalidStrings = [ + "-0000000-01-01T00:02Z[UTC]", + "-0000000-01-01T00:02+00:00[UTC]", + "-0000000-01-01T00:02:00.000000000+00:00[UTC]", +]; -assert.throws(RangeError, () => { Temporal.ZonedDateTime.from(str); }, "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..007750f204 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-year-zero.js new file mode 100644 index 0000000000..9a58704f1f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-string-year-zero.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.equals +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.equals({ year: 2020, month: 5, day: 2, timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.equals({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js index f7030e4d6a..3e87ae8893 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js @@ -4,11 +4,20 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-0000000-01-01T00:02Z[UTC]", + "-0000000-01-01T00:02+00:00[UTC]", + "-0000000-01-01T00:02:00.000000000+00:00[UTC]", +]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "-0000000-01-01T00:02:00.000000000+00:00[UTC]"; - -assert.throws(RangeError, () => { instance.equals(str); }, "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.equals(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..30d5f0cf5f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-year-zero.js new file mode 100644 index 0000000000..4c4cd97e92 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-string-year-zero.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.since +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.since({ year: 2020, month: 5, day: 2, timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.since({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js index 71271b197b..a33e732fba 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js @@ -4,11 +4,20 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.since description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-0000000-01-01T00:02Z[UTC]", + "-0000000-01-01T00:02+00:00[UTC]", + "-0000000-01-01T00:02:00.000000000+00:00[UTC]", +]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "-0000000-01-01T00:02:00.000000000+00:00[UTC]"; - -assert.throws(RangeError, () => { instance.since(str); }, "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.since(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..f3355384ff --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.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: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-year-zero.js new file mode 100644 index 0000000000..c733c4103e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-string-year-zero.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.until +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.until({ year: 2020, month: 5, day: 2, timeZone }), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.until({ year: 2020, month: 5, day: 2, timeZone: { timeZone } }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js index 0a8b5e6cb1..fb6e140e22 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js @@ -4,11 +4,20 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until description: Negative zero, as an extended year, is rejected -features: [Temporal] +features: [Temporal, arrow-function] ---*/ +const invalidStrings = [ + "-0000000-01-01T00:02Z[UTC]", + "-0000000-01-01T00:02+00:00[UTC]", + "-0000000-01-01T00:02:00.000000000+00:00[UTC]", +]; const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.ZonedDateTime(0n, timeZone); -const str = "-0000000-01-01T00:02:00.000000000+00:00[UTC]"; - -assert.throws(RangeError, () => { instance.until(str); }, "reject minus zero as extended year"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.until(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..5bd85409f3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.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.withplaindate +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainDate(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js index 0c66b19fd1..af58036ea9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js @@ -7,11 +7,18 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -assert.throws( +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.withPlainDate(arg); }, + () => instance.withPlainDate(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js index 5d2948efd4..f5fa8e920e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js @@ -9,9 +9,11 @@ features: [Temporal, arrow-function] const invalidStrings = [ "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00[UTC]" + "-000000-12-07T03:24:30+01:00", + "-000000-12-07T03:24:30+00:00[UTC]", ]; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); +const timeZone = new Temporal.TimeZone("UTC"); +const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js new file mode 100644 index 0000000000..fc14d8ed3a --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.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.withtimezone +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +invalidStrings.forEach((timeZone) => { + assert.throws( + RangeError, + () => instance.withTimeZone(timeZone), + "reject minus zero as extended year" + ); + assert.throws( + RangeError, + () => instance.withTimeZone({ timeZone }), + "reject minus zero as extended year (nested property)" + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..ccdbfd4728 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.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.calendar.prototype.era +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.era(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/year-zero.js b/test/intl402/Temporal/Calendar/prototype/era/year-zero.js index ed3d5134f7..a9230724b7 100644 --- a/test/intl402/Temporal/Calendar/prototype/era/year-zero.js +++ b/test/intl402/Temporal/Calendar/prototype/era/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.era(arg); }, + () => instance.era(arg), "reject minus zero as extended year" -); + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js new file mode 100644 index 0000000000..3007055aec --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.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.calendar.prototype.erayear +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T17:45", + "-000000-10-31T17:45Z", + "-000000-10-31T17:45+01:00", + "-000000-10-31T17:45+00:00[UTC]", +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.eraYear(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js b/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js index 22bcccd92c..52cb511a15 100644 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js @@ -7,11 +7,17 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const arg = "-000000-10-31"; +const invalidStrings = [ + "-000000-10-31", + "-000000-10-31T00:45", + "-000000-10-31T00:45+01:00", + "-000000-10-31T00:45+00:00[UTC]", +]; const instance = new Temporal.Calendar("iso8601"); - -assert.throws( +invalidStrings.forEach((arg) => { + assert.throws( RangeError, - () => { instance.eraYear(arg); }, + () => instance.eraYear(arg), "reject minus zero as extended year" -); + ); +});