From 9b2c98c02b2de615195fe3f622072124d23d60d9 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 7 Apr 2022 18:27:47 -0700 Subject: [PATCH] Bring existing "invalid string" tests for smallestUnit and largestUnit in sync Add a consistent set of invalid strings for all of the smallestunit-invalid-string.js and largestunit-invalid-string.js tests: - "era" and "eraYear" in singular and plural - all of the units that are disallowed for that particular method call, in singular and plural - an allowed unit with \0 at the end - an allowed unit with an "i" replaced by a dotless i - an allowed unit but with all-caps - an unrelated string. --- .../round/smallestunit-invalid-string.js | 18 +++++++++- .../toString/smallestunit-invalid-string.js | 31 +++++++++++++++-- .../round/smallestunit-invalid-string.js | 26 ++++++++++++++- .../since/largestunit-invalid-string.js | 27 +++++++++++++-- .../since/smallestunit-invalid-string.js | 27 +++++++++++++-- .../toString/smallestunit-invalid-string.js | 28 +++++++++++++++- .../until/largestunit-invalid-string.js | 27 +++++++++++++-- .../until/smallestunit-invalid-string.js | 27 +++++++++++++-- .../since/largestunit-invalid-string.js | 29 ++++++++++++++-- .../since/smallestunit-invalid-string.js | 29 ++++++++++++++-- .../until/largestunit-invalid-string.js | 29 ++++++++++++++-- .../until/smallestunit-invalid-string.js | 29 ++++++++++++++-- .../round/smallestunit-invalid-string.js | 24 +++++++++++++- .../since/largestunit-invalid-string.js | 19 +++++++++-- .../since/smallestunit-invalid-string.js | 19 +++++++++-- .../toString/smallestunit-invalid-string.js | 28 +++++++++++++++- .../until/largestunit-invalid-string.js | 19 +++++++++-- .../until/smallestunit-invalid-string.js | 19 +++++++++-- .../round/smallestunit-invalid-string.js | 27 +++++++++++++-- .../since/largestunit-invalid-string.js | 27 +++++++++++++-- .../since/smallestunit-invalid-string.js | 27 +++++++++++++-- .../toString/smallestunit-invalid-string.js | 28 ++++++++++++++-- .../until/largestunit-invalid-string.js | 27 +++++++++++++-- .../until/smallestunit-invalid-string.js | 27 +++++++++++++-- .../since/largestunit-invalid-string.js | 33 +++++++++++++++++-- .../since/smallestunit-invalid-string.js | 33 +++++++++++++++++-- .../until/largestunit-invalid-string.js | 33 +++++++++++++++++-- .../until/smallestunit-invalid-string.js | 33 +++++++++++++++++-- .../round/smallestunit-invalid-string.js | 24 +++++++++++++- .../since/largestunit-invalid-string.js | 19 +++++++++-- .../since/smallestunit-invalid-string.js | 19 +++++++++-- .../toString/smallestunit-invalid-string.js | 28 +++++++++++++++- .../until/largestunit-invalid-string.js | 19 +++++++++-- .../until/smallestunit-invalid-string.js | 19 +++++++++-- 34 files changed, 791 insertions(+), 87 deletions(-) diff --git a/test/built-ins/Temporal/Duration/prototype/round/smallestunit-invalid-string.js b/test/built-ins/Temporal/Duration/prototype/round/smallestunit-invalid-string.js index 3d5d884b527..0904c0ccc84 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Duration/prototype/round/smallestunit-invalid-string.js @@ -8,4 +8,20 @@ features: [Temporal] ---*/ const duration = new Temporal.Duration(0, 0, 0, 0, 12, 34, 56, 123, 987, 500); -assert.throws(RangeError, () => duration.round({ smallestUnit: "other string" })); +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/toString/smallestunit-invalid-string.js b/test/built-ins/Temporal/Duration/prototype/toString/smallestunit-invalid-string.js index 046b4a99f70..5405996c5df 100644 --- a/test/built-ins/Temporal/Duration/prototype/toString/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Duration/prototype/toString/smallestunit-invalid-string.js @@ -8,7 +8,32 @@ features: [Temporal] ---*/ const duration = new Temporal.Duration(0, 0, 0, 0, 12, 34, 56, 123, 987, 500); -const values = ["eras", "years", "months", "weeks", "days", "hours", "minutes", "nonsense", "other string", "mill\u0131seconds", "SECONDS"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => duration.toString({ smallestUnit })); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "hour", + "minute", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "hours", + "minutes", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => duration.toString({ smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/Instant/prototype/round/smallestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/round/smallestunit-invalid-string.js index 298c3ce64d6..37560379091 100644 --- a/test/built-ins/Temporal/Instant/prototype/round/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/round/smallestunit-invalid-string.js @@ -8,4 +8,28 @@ features: [Temporal] ---*/ const instant = new Temporal.Instant(1_000_000_000_123_987_500n); -assert.throws(RangeError, () => instant.round({ smallestUnit: "other string" })); +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/since/largestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/since/largestunit-invalid-string.js index 57aa9977ef2..48befae1256 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.Instant(1_000_000_000_000_000_000n); const later = new Temporal.Instant(1_000_090_061_987_654_321n); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +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 largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/Instant/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/since/smallestunit-invalid-string.js index 0e91f3e745d..25f795a89ae 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.Instant(1_000_000_000_000_000_000n); const later = new Temporal.Instant(1_000_090_061_987_654_321n); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +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, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/Instant/prototype/toString/smallestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/toString/smallestunit-invalid-string.js index f6ba6e30cc6..10b0b72baab 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/smallestunit-invalid-string.js @@ -8,4 +8,30 @@ features: [Temporal] ---*/ const instant = new Temporal.Instant(1_000_000_000_123_987_500n); -assert.throws(RangeError, () => instant.toString({ smallestUnit: "other string" })); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "hour", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "hours", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => instant.toString({ smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/Instant/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/until/largestunit-invalid-string.js index 9d288cd6d6d..0837ea1dbb1 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.Instant(1_000_000_000_000_000_000n); const later = new Temporal.Instant(1_000_090_061_987_654_321n); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +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 largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/Instant/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/Instant/prototype/until/smallestunit-invalid-string.js index 145ea2b808e..146b390014e 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/Instant/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.Instant(1_000_000_000_000_000_000n); const later = new Temporal.Instant(1_000_090_061_987_654_321n); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +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, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-invalid-string.js index 9b31fbaabcb..3b047aa86aa 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,30 @@ features: [Temporal] const earlier = new Temporal.PlainDate(2000, 5, 2); const later = new Temporal.PlainDate(2001, 6, 3); -const values = ["era", "eraYear", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/since/smallestunit-invalid-string.js index b06b57f530a..2bc9968ca67 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,30 @@ features: [Temporal] const earlier = new Temporal.PlainDate(2000, 5, 2); const later = new Temporal.PlainDate(2001, 6, 3); -const values = ["era", "eraYear", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +const badValues = [ + "era", + "eraYear", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-invalid-string.js index b06f5d6ed85..379dd28424d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,30 @@ features: [Temporal] const earlier = new Temporal.PlainDate(2000, 5, 2); const later = new Temporal.PlainDate(2001, 6, 3); -const values = ["era", "eraYear", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDate/prototype/until/smallestunit-invalid-string.js index 3eb01aaee89..8382c5c924c 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,30 @@ features: [Temporal] const earlier = new Temporal.PlainDate(2000, 5, 2); const later = new Temporal.PlainDate(2001, 6, 3); -const values = ["era", "eraYear", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +const badValues = [ + "era", + "eraYear", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-invalid-string.js index e4d8f8503c1..f37ebe513cc 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/round/smallestunit-invalid-string.js @@ -8,4 +8,26 @@ features: [Temporal] ---*/ const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500); -assert.throws(RangeError, () => datetime.round({ smallestUnit: "other string" })); +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/since/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/largestunit-invalid-string.js index 1e8f9c80548..547667d70d3 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0); const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/smallestunit-invalid-string.js index a031b3f0fff..6fc80aa6a06 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0); const later = new Temporal.PlainDateTime(2000, 5, 3, 13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +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, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-invalid-string.js index 1d1a6aaeca2..10e19530c1a 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/smallestunit-invalid-string.js @@ -8,4 +8,30 @@ features: [Temporal] ---*/ const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500); -assert.throws(RangeError, () => datetime.toString({ smallestUnit: "other string" })); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "hour", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "hours", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => datetime.toString({ smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/largestunit-invalid-string.js index a3cf0f6aff3..aa7ca9a4c34 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0); const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-invalid-string.js index 781434f7af6..d12bb40e32c 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0); const later = new Temporal.PlainDateTime(2000, 5, 3, 13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +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, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-invalid-string.js index 1da2034e113..917a5a409d2 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/round/smallestunit-invalid-string.js @@ -8,7 +8,28 @@ features: [Temporal] ---*/ const time = new Temporal.PlainTime(12, 34, 56, 123, 987, 500); -const values = ["era", "year", "month", "week", "day", "years", "months", "weeks", "days", "nonsense", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => time.round({ smallestUnit })); +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/since/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/since/largestunit-invalid-string.js index f74105aba51..0faa16156a0 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0); const later = new Temporal.PlainTime(13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +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 largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/since/smallestunit-invalid-string.js index de440191cf2..b375626bf59 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0); const later = new Temporal.PlainTime(13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +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, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainTime/prototype/toString/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/toString/smallestunit-invalid-string.js index d5ea0a7b3e7..d093928a489 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/toString/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/toString/smallestunit-invalid-string.js @@ -8,6 +8,30 @@ features: [Temporal] ---*/ const time = new Temporal.PlainTime(12, 34, 56, 123, 987, 500); -for (const smallestUnit of ["era", "year", "month", "day", "hour", "nonsense", "other string", "m\u0131nute", "SECOND"]) { - assert.throws(RangeError, () => time.toString({ smallestUnit })); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "hour", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "hours", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => time.toString({ smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/until/largestunit-invalid-string.js index 7fcf10a557b..ff95f0e7832 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0); const later = new Temporal.PlainTime(13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +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 largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/until/smallestunit-invalid-string.js index 7225494a217..62ca4957d27 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,28 @@ features: [Temporal] const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0); const later = new Temporal.PlainTime(13, 35, 57, 987, 654, 321); -const values = ["era", "eraYear", "years", "months", "weeks", "days", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +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, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-invalid-string.js index 09b7687f263..00a668d252d 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,34 @@ features: [Temporal] const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2001, 6); -const values = ["era", "eraYear", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "week", + "day", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "weeks", + "days", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-invalid-string.js index 21b0c4b6983..f8e1f541a06 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,34 @@ features: [Temporal] const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2001, 6); -const values = ["era", "eraYear", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +const badValues = [ + "era", + "eraYear", + "week", + "day", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "weeks", + "days", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/largestunit-invalid-string.js index bb243a89914..e3055ec8c49 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,34 @@ features: [Temporal] const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2001, 6); -const values = ["era", "eraYear", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "week", + "day", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "weeks", + "days", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/smallestunit-invalid-string.js index 9e494305079..07095eaf3f4 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,34 @@ features: [Temporal] const earlier = new Temporal.PlainYearMonth(2000, 5); const later = new Temporal.PlainYearMonth(2001, 6); -const values = ["era", "eraYear", "weeks", "days", "hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +const badValues = [ + "era", + "eraYear", + "week", + "day", + "hour", + "minute", + "second", + "millisecond", + "microsecond", + "nanosecond", + "month\0", + "YEAR", + "eras", + "eraYears", + "weeks", + "days", + "hours", + "minutes", + "seconds", + "milliseconds", + "microseconds", + "nanoseconds", + "months\0", + "YEARS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-invalid-string.js index bee6892ba97..cf8831a9756 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallestunit-invalid-string.js @@ -8,4 +8,26 @@ features: [Temporal] ---*/ const datetime = new Temporal.ZonedDateTime(1_000_000_000_123_987_500n, "UTC"); -assert.throws(RangeError, () => datetime.round({ smallestUnit: "other string" })); +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/since/largestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/largestunit-invalid-string.js index 61dd7f3ad39..9e96e8a4965 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/largestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const later = new Temporal.ZonedDateTime(1_000_090_061_987_654_321n, "UTC"); -const values = ["era", "eraYear", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => later.since(earlier, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/smallestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/smallestunit-invalid-string.js index 5735fba65e7..a116e240745 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/smallestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const later = new Temporal.ZonedDateTime(1_000_090_061_987_654_321n, "UTC"); -const values = ["era", "eraYear", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => later.since(earlier, { smallestUnit })); +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, () => later.since(earlier, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/smallestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/smallestunit-invalid-string.js index d3940464811..1ba9732789b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/smallestunit-invalid-string.js @@ -8,4 +8,30 @@ features: [Temporal] ---*/ const datetime = new Temporal.ZonedDateTime(1_000_000_000_123_987_500n, "UTC"); -assert.throws(RangeError, () => datetime.toString({ smallestUnit: "other string" })); +const badValues = [ + "era", + "eraYear", + "year", + "month", + "week", + "day", + "hour", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "years", + "months", + "weeks", + "days", + "hours", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string", +]; +for (const smallestUnit of badValues) { + assert.throws(RangeError, () => datetime.toString({ smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-invalid-string.js index a59c2f2e43c..2be916f1778 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/largestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const later = new Temporal.ZonedDateTime(1_000_090_061_987_654_321n, "UTC"); -const values = ["era", "eraYear", "other string"]; -for (const largestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { largestUnit })); +const badValues = [ + "era", + "eraYear", + "millisecond\0", + "mill\u0131second", + "SECOND", + "eras", + "eraYears", + "milliseconds\0", + "mill\u0131seconds", + "SECONDS", + "other string" +]; +for (const largestUnit of badValues) { + assert.throws(RangeError, () => earlier.until(later, { largestUnit }), + `"${largestUnit}" is not a valid value for largestUnit`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/smallestunit-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/smallestunit-invalid-string.js index 42f55bc8503..4f09f10f688 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/smallestunit-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/smallestunit-invalid-string.js @@ -9,7 +9,20 @@ features: [Temporal] const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const later = new Temporal.ZonedDateTime(1_000_090_061_987_654_321n, "UTC"); -const values = ["era", "eraYear", "other string"]; -for (const smallestUnit of values) { - assert.throws(RangeError, () => earlier.until(later, { smallestUnit })); +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, () => earlier.until(later, { smallestUnit }), + `"${smallestUnit}" is not a valid value for smallest unit`); }