Skip to content

Commit

Permalink
Test more invalid values for roundingMode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Mar 11, 2022
1 parent 51ce1fa commit 104e5e8
Show file tree
Hide file tree
Showing 22 changed files with 56 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}

0 comments on commit 104e5e8

Please sign in to comment.