diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js new file mode 100644 index 00000000000..91e4a0a1ddc --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.dateAdd(arg); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js new file mode 100644 index 00000000000..effb46112b5 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/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.dateuntil +description: Negative zero, as extended year, is invalid +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +const date = new Temporal.PlainDate(2000, 5, 2); +const bad = "-000000-03-14"; + +assert.throws( + RangeError, + () => calendar.dateUntil(bad, 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)" +); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js new file mode 100644 index 00000000000..555a3f62c0f --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.day(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 new file mode 100644 index 00000000000..18ab7a6827b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.dayOfWeek(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 new file mode 100644 index 00000000000..e31b2141169 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.dayOfYear(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 new file mode 100644 index 00000000000..c2c6204ed69 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.daysInMonth(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 new file mode 100644 index 00000000000..b852ef78140 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.daysInWeek(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 new file mode 100644 index 00000000000..4c226015b22 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.daysInYear(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 new file mode 100644 index 00000000000..8aeb7c2a761 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.inLeapYear(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 new file mode 100644 index 00000000000..f42751175ad --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.month(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 new file mode 100644 index 00000000000..fc81c5348e2 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.monthCode(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 new file mode 100644 index 00000000000..0451a665599 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.monthsInYear(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 new file mode 100644 index 00000000000..44eeabb3218 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.weekOfYear(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 new file mode 100644 index 00000000000..6221b7db925 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.year(arg); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Duration/compare/year-zero.js b/test/built-ins/Temporal/Duration/compare/year-zero.js new file mode 100644 index 00000000000..b0088aabda9 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/year-zero.js @@ -0,0 +1,18 @@ +// Copyright (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, fails +features: [Temporal] +---*/ + +const duration1 = new Temporal.Duration(1); +const duration2 = new Temporal.Duration(2); +const bad = "-000000-11-01"; + +assert.throws( + RangeError, + () => Temporal.Duration.compare(duration1, duration2, { relativeTo: bad }), + "Cannot use negative zero as extended year" +); diff --git a/test/built-ins/Temporal/Duration/prototype/add/year-zero.js b/test/built-ins/Temporal/Duration/prototype/add/year-zero.js new file mode 100644 index 00000000000..cf807d355bb --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 instance = new Temporal.Duration(1, 0, 0, 1); + +let relativeTo = "-000000-11-04T00:00"; +assert.throws( + RangeError, + () => { instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Duration/prototype/round/year-zero.js b/test/built-ins/Temporal/Duration/prototype/round/year-zero.js new file mode 100644 index 00000000000..041f7c26b8a --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 instance = new Temporal.Duration(1, 0, 0, 0, 24); + +let relativeTo = "-000000-11-04T00:00"; +assert.throws( + RangeError, + () => { instance.round({ largestUnit: "years", relativeTo }); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/year-zero.js b/test/built-ins/Temporal/Duration/prototype/subtract/year-zero.js new file mode 100644 index 00000000000..bee08e7a148 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 instance = new Temporal.Duration(1, 0, 0, 1); + +let relativeTo = "-000000-11-04T00:00"; +assert.throws( + RangeError, + () => { instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Duration/prototype/total/year-zero.js b/test/built-ins/Temporal/Duration/prototype/total/year-zero.js new file mode 100644 index 00000000000..28d72b9ed1a --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 instance = new Temporal.Duration(1, 0, 0, 0, 24); + +let relativeTo = "-000000-11-04T00:00"; +assert.throws( + RangeError, + () => { instance.total({ unit: "days", relativeTo }); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/Instant/compare/year-zero.js b/test/built-ins/Temporal/Instant/compare/year-zero.js new file mode 100644 index 00000000000..e6bb684d438 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/year-zero.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.compare +description: Negative zero, as an extended year, fails +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const bad = '-000000-03-30T00:45Z'; + +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)" +); diff --git a/test/built-ins/Temporal/Instant/from/year-zero.js b/test/built-ins/Temporal/Instant/from/year-zero.js new file mode 100644 index 00000000000..b21396b8948 --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.from +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "-000000-03-31T00:45Z", + "-000000-03-31T01:45+01:00", + "-000000-03-31T01:45:00+01:00[UTC]" +]; + +invalidStrings.forEach((str) => { + assert.throws( + RangeError, + () => Temporal.Instant.from(str), + "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 new file mode 100644 index 00000000000..d2932d28889 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.equals +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+01:00[UTC]" +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((str) => { + assert.throws( + RangeError, + () => instance.equals(str), + "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 new file mode 100644 index 00000000000..38bf10fd673 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.since +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+01:00[UTC]" +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((str) => { + assert.throws( + RangeError, + () => instance.since(str), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/Instant/prototype/until/year-zero.js b/test/built-ins/Temporal/Instant/prototype/until/year-zero.js new file mode 100644 index 00000000000..28953c09e54 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.until +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+01:00[UTC]" +]; +const instance = new Temporal.Instant(0n); +invalidStrings.forEach((str) => { + assert.throws( + RangeError, + () => instance.until(str), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/compare/year-zero.js b/test/built-ins/Temporal/PlainDate/compare/year-zero.js new file mode 100644 index 00000000000..75f79cf98e9 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Negative zero, as an extended year, fails +esid: sec-temporal.plaindate.compare +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); +const bad = "-000000-08-24"; + +assert.throws(RangeError, + () => Temporal.PlainDate.compare(bad, 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)" +); diff --git a/test/built-ins/Temporal/PlainDate/from/year-zero.js b/test/built-ins/Temporal/PlainDate/from/year-zero.js new file mode 100644 index 00000000000..0e000677f21 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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] +---*/ + +const arg = "-000000-10-31"; + +assert.throws( + RangeError, + () => { Temporal.PlainDate.from(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 new file mode 100644 index 00000000000..486a5da1ac2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws( + RangeError, + () => { instance.equals(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 new file mode 100644 index 00000000000..9f83cc531c0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws( + RangeError, + () => { 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 new file mode 100644 index 00000000000..0e1d2834749 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.toplaindatetime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toPlainDateTime(arg), + "reject minus zero as extended year" + ); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js new file mode 100644 index 00000000000..33387244aae --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainDate(2000, 5, 2); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), + "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 new file mode 100644 index 00000000000..28a78617277 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainDate(2000, 5, 2); + +assert.throws( + RangeError, + () => { instance.until(arg); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js b/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js new file mode 100644 index 00000000000..f32f6cb0e31 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Negative zero, as an extended year, fails +esid: sec-temporal.plaindatetime.compare +features: [Temporal] +---*/ + +const ok = new Temporal.PlainDateTime(2000, 5, 2, 15); +const bad = "-000000-12-07T03:24:30"; + +assert.throws(RangeError, + () => Temporal.PlainDateTime.compare(bad,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)" +); diff --git a/test/built-ins/Temporal/PlainDateTime/from/year-zero.js b/test/built-ins/Temporal/PlainDateTime/from/year-zero.js new file mode 100644 index 00000000000..7f21302a3bc --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/year-zero.js @@ -0,0 +1,20 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js new file mode 100644 index 00000000000..175c2d70166 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/since/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js new file mode 100644 index 00000000000..e7b6146a579 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/until/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js new file mode 100644 index 00000000000..028410a06d5 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/withPlainDate/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js new file mode 100644 index 00000000000..392a7ec2c07 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +assert.throws( + RangeError, + () => { 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 new file mode 100644 index 00000000000..0b74c516c6c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withplaintime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(arg), + "reject 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 new file mode 100644 index 00000000000..347dba09282 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-08", + "-000000-08-24", + "-000000-08-24T15:43:27", + "-000000-08-24T15:43:27+01: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/prototype/equals/year-zero.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js new file mode 100644 index 00000000000..f420f38b46a --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + "-000000-08", + "-000000-08-24", + "-000000-08-24T15:43:27", + "-000000-08-24T15:43:27+01: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/PlainTime/compare/year-zero.js b/test/built-ins/Temporal/PlainTime/compare/year-zero.js new file mode 100644 index 00000000000..470b42fda1c --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/compare/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.compare +description: Negative zero, as an extended year, fails +features: [Temporal] +---*/ + +const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); +const bad = "-000000-12-07T03:24:30"; + +assert.throws( + RangeError, + () => Temporal.PlainTime.compare(bad, 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)" +); diff --git a/test/built-ins/Temporal/PlainTime/from/year-zero.js b/test/built-ins/Temporal/PlainTime/from/year-zero.js new file mode 100644 index 00000000000..671e5c5c68a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/year-zero.js @@ -0,0 +1,20 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.from +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => { 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 new file mode 100644 index 00000000000..c58365d4b05 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.equals +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainTime(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/PlainTime/prototype/since/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js new file mode 100644 index 00000000000..1124fe8a771 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.since +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainTime(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/PlainTime/prototype/toPlainDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js new file mode 100644 index 00000000000..481f20b37af --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws( + RangeError, + () => { instance.toPlainDateTime(arg); }, + "reject minus zero as extended year" +); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js new file mode 100644 index 00000000000..d5381ad4050 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +assert.throws( + RangeError, + () => { instance.toZonedDateTime({ plainDate: arg }); }, + "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 new file mode 100644 index 00000000000..759782e9bb1 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.until +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.PlainTime(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/PlainYearMonth/compare/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js new file mode 100644 index 00000000000..5d1a6cd03ee --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Negative zero, as an extended year, fails +esid: sec-temporal.plainyearmonth.compare +features: [Temporal] +---*/ + +const ok = new Temporal.PlainYearMonth(2000, 5); +const bad = "-000000-06"; + +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.compare(bad, 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)" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js new file mode 100644 index 00000000000..1d8c7b3af73 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +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]' +]; +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => { Temporal.PlainYearMonth.from(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 new file mode 100644 index 00000000000..9ab97736fd5 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-06', + '-000000-06-24', + '-000000-06-24T15:43:27', + '-000000-06-24T15:43:27+01: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/since/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js new file mode 100644 index 00000000000..e1b96103831 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-06', + '-000000-06-24', + '-000000-06-24T15:43:27', + '-000000-06-24T15:43:27+01: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/until/year-zero.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js new file mode 100644 index 00000000000..b2f534aeff7 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: RangeError thrown if a string with UTC designator is used as a PlainYearMonth +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-06', + '-000000-06-24', + '-000000-06-24T15:43:27', + '-000000-06-24T15:43:27+01: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/TimeZone/prototype/getInstantFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js new file mode 100644 index 00000000000..dfa1f9121d0 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/getNextTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js new file mode 100644 index 00000000000..f93af181509 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getnexttransition +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +let str = "-000000-01-01T00:00"; +assert.throws(RangeError, () => instance.getNextTransition(str), "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 new file mode 100644 index 00000000000..91275f98364 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +let str = "-000000-01-01T00:00"; +assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "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 new file mode 100644 index 00000000000..3840a51ff8f --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getoffsetstringfor +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +let str = "-000000-01-01T00:00"; +assert.throws(RangeError, () => instance.getOffsetStringFor(str), "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 new file mode 100644 index 00000000000..d15162a5e7e --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js @@ -0,0 +1,22 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getplaindatetimefor +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const invalidStrings = [ + "-000000-03-30T00:45Z", + "-000000-03-30T01:45+01:00", + "-000000-03-30T01:45:00+01:00[UTC]" +]; +const instance = new Temporal.TimeZone("UTC"); +invalidStrings.forEach((str) => { + assert.throws( + RangeError, + () => instance.getPlainDateTimeFor(str), + "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 new file mode 100644 index 00000000000..e6efaf6004a --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (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-12-07T03:24:30", + "-000000-12-07T03:24:30+01: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/getPreviousTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js new file mode 100644 index 00000000000..55865672105 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.prototype.getprevioustransition +description: Negative zero, as an extended year, is rejected +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +let str = "-000000-01-01T00:00"; +assert.throws(RangeError, () => instance.getPreviousTransition(str), "reject minus zero as extended year"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js new file mode 100644 index 00000000000..314b364b42d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/year-zero.js @@ -0,0 +1,20 @@ +// Copyright (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, fails +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); +const bad = "-000000-08-19T17:30Z"; + +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)" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js new file mode 100644 index 00000000000..da7638028a0 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/year-zero.js @@ -0,0 +1,12 @@ +// Copyright (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] +---*/ + +const str = "-0000000-01-01T00:02:00.000000000+00:00[UTC]"; + +assert.throws(RangeError, () => { Temporal.ZonedDateTime.from(str); }, "reject minus zero as extended year"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js new file mode 100644 index 00000000000..f7030e4d6a9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js @@ -0,0 +1,14 @@ +// Copyright (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] +---*/ + +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"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js new file mode 100644 index 00000000000..71271b197b4 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js @@ -0,0 +1,14 @@ +// Copyright (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] +---*/ + +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"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js new file mode 100644 index 00000000000..0a8b5e6cb16 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js @@ -0,0 +1,14 @@ +// Copyright (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] +---*/ + +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"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js new file mode 100644 index 00000000000..0c66b19fd14 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); + +assert.throws( + RangeError, + () => { 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 new file mode 100644 index 00000000000..13f6ae25186 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withplaintime +description: Negative zero, as an extended year, is rejected +features: [Temporal, arrow-function] +---*/ + +const invalidStrings = [ + '-000000-12-07T03:24:30', + '-000000-12-07T03:24:30+01:00[UTC]' +]; +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); +invalidStrings.forEach((arg) => { + assert.throws( + RangeError, + () => instance.withPlainTime(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 new file mode 100644 index 00000000000..ed3d5134f74 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.era(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 new file mode 100644 index 00000000000..22bcccd92cf --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js @@ -0,0 +1,17 @@ +// Copyright (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 arg = "-000000-10-31"; +const instance = new Temporal.Calendar("iso8601"); + +assert.throws( + RangeError, + () => { instance.eraYear(arg); }, + "reject minus zero as extended year" +);