mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Remove the existing "instant-string-limits.js" that only applied to APIs where ToTemporalInstant was called. Add "argument-string-limits.js" tests everywhere ISO strings are converted. Related to tc39/proposal-temporal#2985
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.plainyearmonth.compare
|
|
description: ISO strings at the edges of the representable range
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
const instance = new Temporal.PlainYearMonth(2019, 6);
|
|
|
|
const validStrings = [
|
|
"-271821-04",
|
|
"-271821-04-01",
|
|
"-271821-04-01T00:00",
|
|
"+275760-09",
|
|
"+275760-09-30",
|
|
"+275760-09-30T23:59:59.999999999",
|
|
];
|
|
|
|
for (const arg of validStrings) {
|
|
Temporal.PlainYearMonth.compare(arg, instance);
|
|
Temporal.PlainYearMonth.compare(instance, arg);
|
|
}
|
|
|
|
const invalidStrings = [
|
|
"-271821-03-31",
|
|
"-271821-03-31T23:59:59.999999999",
|
|
"+275760-10",
|
|
"+275760-10-01",
|
|
"+275760-10-01T00:00",
|
|
];
|
|
|
|
for (const arg of invalidStrings) {
|
|
assert.throws(
|
|
RangeError,
|
|
() => Temporal.PlainYearMonth.compare(arg, instance),
|
|
`"${arg}" is outside the representable range of PlainYearMonth (first argument)`
|
|
);
|
|
assert.throws(
|
|
RangeError,
|
|
() => Temporal.PlainYearMonth.compare(instance, arg),
|
|
`"${arg}" is outside the representable range of PlainYearMonth (second argument)`
|
|
);
|
|
}
|