diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundto-invalid-string.js b/test/built-ins/Temporal/Duration/prototype/round/roundto-invalid-string.js new file mode 100644 index 0000000000..3e5a43386b --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/roundto-invalid-string.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.duration.prototype.round +description: RangeError thrown when smallestUnit option not one of the allowed string values +features: [Temporal] +---*/ + +const duration = new Temporal.Duration(0, 0, 0, 0, 12, 34, 56, 123, 987, 500); +const badValues = [ + "era", + "eraYear", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => duration.round(smallestUnit), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/Duration/prototype/round/smallestunit-disallowed-units-string.js b/test/built-ins/Temporal/Duration/prototype/round/smallestunit-disallowed-units-string.js deleted file mode 100644 index f2cf0b0f01..0000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/smallestunit-disallowed-units-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: Specifically disallowed units for the smallestUnit option -features: [Temporal, arrow-function] ----*/ - -const instance = new Temporal.Duration(0, 0, 0, 4, 5, 6, 7, 987, 654, 321); -const invalidUnits = [ - "era", - "eras", -]; -invalidUnits.forEach((smallestUnit) => { - assert.throws( - RangeError, - () => instance.round({ smallestUnit }), - `{ smallestUnit: "${smallestUnit}" } should not be allowed as an argument to round` - ); - assert.throws( - RangeError, - () => instance.round(smallestUnit), - `"${smallestUnit}" should not be allowed as an argument to round` - ); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/round/roundto-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/round/roundto-invalid-string.js new file mode 100644 index 0000000000..db76bcd23f --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/round/roundto-invalid-string.js @@ -0,0 +1,35 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.round +description: RangeError thrown when smallestUnit option not one of the allowed string values +features: [Temporal] +---*/ + +const instant = new Temporal.Instant(1_000_000_000_123_987_500n); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => instant.round(smallestUnit), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/Instant/prototype/round/smallestunit-disallowed-units.js b/test/built-ins/Temporal/Instant/prototype/round/smallestunit-disallowed-units.js deleted file mode 100644 index 2d7dcb1d5f..0000000000 --- a/test/built-ins/Temporal/Instant/prototype/round/smallestunit-disallowed-units.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.round -description: Specifically disallowed units for the smallestUnit option -features: [Temporal, arrow-function] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_987_654_321n); -const invalidUnits = [ - "era", - "eras", - "year", - "month", - "week", - "years", - "months", - "weeks", - "day", - "days", -]; -invalidUnits.forEach((smallestUnit) => { - assert.throws( - RangeError, - () => instance.round({ smallestUnit }), - `{ smallestUnit: "${smallestUnit}" } should not be allowed as an argument to round` - ); - assert.throws( - RangeError, - () => instance.round(smallestUnit), - `"${smallestUnit}" should not be allowed as an argument to round` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/round/roundto-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/round/roundto-invalid-string.js new file mode 100644 index 0000000000..184d11731c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/round/roundto-invalid-string.js @@ -0,0 +1,33 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.round +description: RangeError thrown when smallestUnit option not one of the allowed string values +features: [Temporal] +---*/ + +const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => datetime.round(smallestUnit), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-disallowed-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-disallowed-units.js deleted file mode 100644 index cd85d00ae1..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-disallowed-units.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.round -description: Specifically disallowed units for the smallestUnit option -features: [Temporal, arrow-function] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 789, 999, 999); -const invalidUnits = [ - "era", - "eras", - "year", - "month", - "week", - "years", - "months", - "weeks", -]; -invalidUnits.forEach((smallestUnit) => { - assert.throws( - RangeError, - () => instance.round({ smallestUnit }), - `{ smallestUnit: "${smallestUnit}" } should not be allowed as an argument to round` - ); - assert.throws( - RangeError, - () => instance.round(smallestUnit), - `"${smallestUnit}" should not be allowed as an argument to round` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/roundto-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/round/roundto-invalid-string.js new file mode 100644 index 0000000000..53a665f951 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/roundto-invalid-string.js @@ -0,0 +1,35 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaintime.prototype.round +description: RangeError thrown when smallestUnit option not one of the allowed string values +features: [Temporal] +---*/ + +const time = new Temporal.PlainTime(12, 34, 56, 123, 987, 500); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => time.round(smallestUnit), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-disallowed-units.js b/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-disallowed-units.js deleted file mode 100644 index 1a9da4e74a..0000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-disallowed-units.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.round -description: Specifically disallowed units for the smallestUnit option -features: [Temporal, arrow-function] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 789, 999, 999); -const invalidUnits = [ - "era", - "eras", - "year", - "month", - "week", - "years", - "months", - "weeks", - "day", - "days", -]; -invalidUnits.forEach((smallestUnit) => { - assert.throws( - RangeError, - () => instance.round({ smallestUnit }), - `{ smallestUnit: "${smallestUnit}" } should not be allowed as an argument to round` - ); - assert.throws( - RangeError, - () => instance.round(smallestUnit), - `"${smallestUnit}" should not be allowed as an argument to round` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/roundto-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/roundto-invalid-string.js new file mode 100644 index 0000000000..9ce1a9e17d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/roundto-invalid-string.js @@ -0,0 +1,33 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.round +description: RangeError thrown when smallestUnit option not one of the allowed string values +features: [Temporal] +---*/ + +const datetime = new Temporal.ZonedDateTime(1_000_000_000_123_987_500n, "UTC"); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => datetime.round(smallestUnit), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-disallowed-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-disallowed-units.js deleted file mode 100644 index f89f4c6752..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-disallowed-units.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: Specifically disallowed units for the smallestUnit option -features: [Temporal, arrow-function] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); -const invalidUnits = [ - "era", - "eras", - "year", - "month", - "week", - "years", - "months", - "weeks", -]; -invalidUnits.forEach((smallestUnit) => { - assert.throws( - RangeError, - () => instance.round({ smallestUnit }), - `{ smallestUnit: "${smallestUnit}" } should not be allowed as an argument to round` - ); - assert.throws( - RangeError, - () => instance.round(smallestUnit), - `"${smallestUnit}" should not be allowed as an argument to round` - ); -});