Test more invalid values for roundingMode.

This commit is contained in:
Ms2ger 2022-03-11 09:51:57 +01:00
parent 51ce1fa00f
commit 104e5e8fab
22 changed files with 56 additions and 24 deletions

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const duration = new Temporal.Duration(0, 0, 0, 0, 12, 34, 56, 123, 987, 500);
assert.throws(RangeError, () => duration.round({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => duration.round({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,6 +8,6 @@ features: [Temporal]
---*/
const duration = new Temporal.Duration(0, 0, 0, 0, 12, 34, 56, 123, 987, 500);
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto"]) {
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => duration.toString({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const instant = new Temporal.Instant(1_000_000_000_123_987_500n);
assert.throws(RangeError, () => instant.round({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => instant.round({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.Instant(1_000_000_000_000_000_000n);
const later = new Temporal.Instant(1_000_090_061_123_987_500n);
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const instant = new Temporal.Instant(1_000_000_000_123_987_500n);
assert.throws(RangeError, () => instant.toString({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => instant.toString({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.Instant(1_000_000_000_000_000_000n);
const later = new Temporal.Instant(1_000_090_061_123_987_500n);
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainDate(2000, 5, 2);
const later = new Temporal.PlainDate(2001, 6, 3);
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainDate(2000, 5, 2);
const later = new Temporal.PlainDate(2001, 6, 3);
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500);
assert.throws(RangeError, () => datetime.round({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => datetime.round({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ 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, 123, 987, 500);
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 987, 500);
assert.throws(RangeError, () => datetime.toString({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => datetime.toString({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ 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, 123, 987, 500);
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,6 +8,6 @@ features: [Temporal]
---*/
const time = new Temporal.PlainTime(12, 34, 56, 123, 987, 500);
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l"]) {
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => time.round({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,7 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0);
const later = new Temporal.PlainTime(13, 35, 57, 123, 987, 500);
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto"]) {
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,6 +8,6 @@ features: [Temporal]
---*/
const time = new Temporal.PlainTime(12, 34, 56, 123, 987, 500);
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l"]) {
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => time.toString({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,7 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainTime(12, 34, 56, 0, 0, 0);
const later = new Temporal.PlainTime(13, 35, 57, 123, 987, 500);
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto"]) {
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainYearMonth(2000, 5);
const later = new Temporal.PlainYearMonth(2001, 6);
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.PlainYearMonth(2000, 5);
const later = new Temporal.PlainYearMonth(2001, 6);
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const datetime = new Temporal.ZonedDateTime(1_000_000_000_123_987_500n, "UTC");
assert.throws(RangeError, () => datetime.round({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => datetime.round({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
const later = new Temporal.ZonedDateTime(1_000_090_061_123_987_500n, "UTC");
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => later.since(earlier, { smallestUnit: "microsecond", roundingMode }));
}

View File

@ -8,4 +8,6 @@ features: [Temporal]
---*/
const datetime = new Temporal.ZonedDateTime(1_000_000_000_123_987_500n, "UTC");
assert.throws(RangeError, () => datetime.toString({ smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => datetime.toString({ smallestUnit: "microsecond", roundingMode }));
}

View File

@ -9,4 +9,6 @@ features: [Temporal]
const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
const later = new Temporal.ZonedDateTime(1_000_090_061_123_987_500n, "UTC");
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode: "other string" }));
for (const roundingMode of ["other string", "cile", "CEIL", "ce\u0131l", "auto", "expand", "halfCeil", "halfFloor", "halfTrunc", "halfEven", "halfexpand", "floor\0"]) {
assert.throws(RangeError, () => earlier.until(later, { smallestUnit: "microsecond", roundingMode }));
}