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.
This commit is contained in:
Philip Chimento 2022-04-07 18:27:47 -07:00 committed by Ms2ger
parent b4c0aeda20
commit 9b2c98c02b
34 changed files with 791 additions and 87 deletions

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}

View File

@ -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`);
}