mirror of https://github.com/tc39/test262.git
Temporal: Consistently test all string entry points for representable range
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
This commit is contained in:
parent
116bc2cc47
commit
326cdb8da8
|
@ -0,0 +1,48 @@
|
|||
// 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.duration.compare
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration();
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of validStrings) {
|
||||
Temporal.Duration.compare(instance, instance, { relativeTo });
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Duration.compare(instance, instance, { relativeTo }),
|
||||
`"${relativeTo}" is outside the representable range for a relativeTo parameter`
|
||||
);
|
||||
}
|
48
test/built-ins/Temporal/Duration/prototype/round/relativeto-string-limits.js
vendored
Normal file
48
test/built-ins/Temporal/Duration/prototype/round/relativeto-string-limits.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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.duration.prototype.round
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration();
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of validStrings) {
|
||||
instance.round({ smallestUnit: "minutes", relativeTo });
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.round({ smallestUnit: "minutes", relativeTo }),
|
||||
`"${relativeTo}" is outside the representable range for a relativeTo parameter`
|
||||
);
|
||||
}
|
48
test/built-ins/Temporal/Duration/prototype/total/relativeto-string-limits.js
vendored
Normal file
48
test/built-ins/Temporal/Duration/prototype/total/relativeto-string-limits.js
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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.duration.prototype.total
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration();
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of validStrings) {
|
||||
instance.total({ unit: "minutes", relativeTo });
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const relativeTo of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.total({ unit: "minutes", relativeTo }),
|
||||
`"${relativeTo}" is outside the representable range for a relativeTo parameter`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 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.instant.compare
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.Instant.compare(arg, instance);
|
||||
Temporal.Instant.compare(instance, arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Instant.compare(arg, instance),
|
||||
`"${arg}" is outside the representable range of Instant (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Instant.compare(instance, arg),
|
||||
`"${arg}" is outside the representable range of Instant (second argument)`
|
||||
);
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.compare
|
||||
description: String arguments at the limit of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const minInstant = new Temporal.Instant(-86400_00000000_000_000_000n);
|
||||
const maxInstant = new Temporal.Instant(86400_00000000_000_000_000n);
|
||||
|
||||
const minInstantStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
];
|
||||
for (const str of minInstantStrings) {
|
||||
assert.sameValue(Temporal.Instant.compare(str, minInstant), 0, `instant string ${str} should be valid (first argument)`);
|
||||
assert.sameValue(Temporal.Instant.compare(minInstant, str), 0, `instant string ${str} should be valid (second argument)`);
|
||||
}
|
||||
|
||||
const maxInstantStrings = [
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of maxInstantStrings) {
|
||||
assert.sameValue(Temporal.Instant.compare(str, maxInstant), 0, `instant string ${str} should be valid (first argument)`);
|
||||
assert.sameValue(Temporal.Instant.compare(maxInstant, str), 0, `instant string ${str} should be valid (second argument)`);
|
||||
}
|
||||
|
||||
const outOfRangeInstantStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of outOfRangeInstantStrings) {
|
||||
assert.throws(RangeError, () => Temporal.Instant.compare(str, minInstant), `instant string ${str} should not be valid (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.Instant.compare(minInstant, str), `instant string ${str} should not be valid (second argument)`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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.instant.from
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.Instant.from(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Instant.from(arg),
|
||||
`"${arg}" is outside the representable range of Instant`
|
||||
);
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.from
|
||||
description: String arguments at the limit of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const minInstant = new Temporal.Instant(-86400_00000000_000_000_000n);
|
||||
const maxInstant = new Temporal.Instant(86400_00000000_000_000_000n);
|
||||
|
||||
const minInstantStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
];
|
||||
for (const str of minInstantStrings) {
|
||||
assert.sameValue(Temporal.Instant.from(str).epochNanoseconds, minInstant.epochNanoseconds, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const maxInstantStrings = [
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of maxInstantStrings) {
|
||||
assert.sameValue(Temporal.Instant.from(str).epochNanoseconds, maxInstant.epochNanoseconds, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const outOfRangeInstantStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of outOfRangeInstantStrings) {
|
||||
assert.throws(RangeError, () => Temporal.Instant.from(str), `instant string ${str} should not be valid`);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// 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.instant.prototype.equals
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.equals(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
`"${arg}" is outside the representable range of Instant`
|
||||
);
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.prototype.equals
|
||||
description: String arguments at the limit of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const minInstant = new Temporal.Instant(-86400_00000000_000_000_000n);
|
||||
const maxInstant = new Temporal.Instant(86400_00000000_000_000_000n);
|
||||
|
||||
const minInstantStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
];
|
||||
for (const str of minInstantStrings) {
|
||||
assert.sameValue(minInstant.equals(str), true, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const maxInstantStrings = [
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of maxInstantStrings) {
|
||||
assert.sameValue(maxInstant.equals(str), true, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const outOfRangeInstantStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of outOfRangeInstantStrings) {
|
||||
assert.throws(RangeError, () => minInstant.equals(str), `instant string ${str} should not be valid`);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// 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.instant.prototype.since
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.since(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`"${arg}" is outside the representable range of Instant`
|
||||
);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.prototype.since
|
||||
description: String arguments at the limit of the representable range
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const minInstant = new Temporal.Instant(-86400_00000000_000_000_000n);
|
||||
const maxInstant = new Temporal.Instant(86400_00000000_000_000_000n);
|
||||
|
||||
const minInstantStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
];
|
||||
for (const str of minInstantStrings) {
|
||||
TemporalHelpers.assertDuration(minInstant.since(str), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const maxInstantStrings = [
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of maxInstantStrings) {
|
||||
TemporalHelpers.assertDuration(maxInstant.since(str), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const outOfRangeInstantStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of outOfRangeInstantStrings) {
|
||||
assert.throws(RangeError, () => minInstant.since(str), `instant string ${str} should not be valid`);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// 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.instant.prototype.until
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.until(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`"${arg}" is outside the representable range of Instant`
|
||||
);
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.instant.prototype.until
|
||||
description: String arguments at the limit of the representable range
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const minInstant = new Temporal.Instant(-86400_00000000_000_000_000n);
|
||||
const maxInstant = new Temporal.Instant(86400_00000000_000_000_000n);
|
||||
|
||||
const minInstantStrings = [
|
||||
"-271821-04-20T00:00Z",
|
||||
"-271821-04-19T23:00-01:00",
|
||||
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
|
||||
];
|
||||
for (const str of minInstantStrings) {
|
||||
TemporalHelpers.assertDuration(minInstant.until(str), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const maxInstantStrings = [
|
||||
"+275760-09-13T00:00Z",
|
||||
"+275760-09-13T01:00+01:00",
|
||||
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of maxInstantStrings) {
|
||||
TemporalHelpers.assertDuration(maxInstant.until(str), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`);
|
||||
}
|
||||
|
||||
const outOfRangeInstantStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z",
|
||||
"-271821-04-19T23:00-00:59:59.999999999",
|
||||
"-271821-04-19T00:00:00-23:59:59.999999999",
|
||||
"+275760-09-13T00:00:00.000000001Z",
|
||||
"+275760-09-13T01:00+00:59:59.999999999",
|
||||
"+275760-09-14T00:00+23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const str of outOfRangeInstantStrings) {
|
||||
assert.throws(RangeError, () => minInstant.until(str), `instant string ${str} should not be valid`);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
// 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.plaindate.compare
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(1976, 11, 18);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.PlainDate.compare(arg, instance);
|
||||
Temporal.PlainDate.compare(instance, arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDate.compare(arg, instance),
|
||||
`"${arg}" is outside the representable range of PlainDate (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDate.compare(instance, arg),
|
||||
`"${arg}" is outside the representable range of PlainDate (second argument)`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// 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.plaindate.from
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.PlainDate.from(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDate.from(arg),
|
||||
`"${arg}" is outside the representable range of PlainDate`
|
||||
);
|
||||
}
|
36
test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-limits.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDate/prototype/equals/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindate.prototype.equals
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.equals(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
`"${arg}" is outside the representable range of PlainDate`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindate.prototype.since
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.since(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`"${arg}" is outside the representable range of PlainDate`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindate.prototype.until
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T01:00",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:00",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.until(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-18",
|
||||
"-271821-04-18T23:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T01:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`"${arg}" is outside the representable range of PlainDate`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
// 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.plaindatetime.compare
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19T00:00:00.000000001",
|
||||
"-271821-04-20",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.PlainDateTime.compare(arg, instance);
|
||||
Temporal.PlainDateTime.compare(instance, arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T00:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDateTime.compare(arg, instance),
|
||||
`"${arg}" is outside the representable range of PlainDateTime (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDateTime.compare(instance, arg),
|
||||
`"${arg}" is outside the representable range of PlainDateTime (second argument)`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
// 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.plaindatetime.from
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19T00:00:00.000000001",
|
||||
"-271821-04-20",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.PlainDateTime.from(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T00:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.PlainDateTime.from(arg),
|
||||
`"${arg}" is outside the representable range of PlainDateTime`
|
||||
);
|
||||
}
|
36
test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-limits.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindatetime.prototype.equals
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19T00:00:00.000000001",
|
||||
"-271821-04-20",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.equals(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T00:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
`"${arg}" is outside the representable range of PlainDateTime`
|
||||
);
|
||||
}
|
36
test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-limits.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/since/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindatetime.prototype.since
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19T00:00:00.000000001",
|
||||
"-271821-04-20",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.since(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T00:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`"${arg}" is outside the representable range of PlainDateTime`
|
||||
);
|
||||
}
|
36
test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-limits.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/until/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindatetime.prototype.until
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-19T00:00:00.000000001",
|
||||
"-271821-04-20",
|
||||
"+275760-09-13",
|
||||
"+275760-09-13T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.until(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19",
|
||||
"-271821-04-19T00:00",
|
||||
"+275760-09-14",
|
||||
"+275760-09-14T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`"${arg}" is outside the representable range of PlainDateTime`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
// 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)`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// 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.from
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
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.from(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.from(arg),
|
||||
`"${arg}" is outside the representable range of PlainYearMonth`
|
||||
);
|
||||
}
|
39
test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-limits.js
vendored
Normal file
39
test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// 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.prototype.equals
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 12);
|
||||
|
||||
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) {
|
||||
instance.equals(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,
|
||||
() => instance.equals(arg),
|
||||
`"${arg}" is outside the representable range of PlainYearMonth`
|
||||
);
|
||||
}
|
45
test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-limits.js
vendored
Normal file
45
test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// 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.prototype.since
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(1970, 1);
|
||||
|
||||
// Note, these limits are different than other PlainYearMonth conversions
|
||||
// because the difference is taken between the first days of the two months, so
|
||||
// the first day of the month of the argument must be within the representable
|
||||
// range
|
||||
|
||||
const validStrings = [
|
||||
"-271821-05",
|
||||
"-271821-05-01",
|
||||
"-271821-05-01T00:00",
|
||||
"+275760-09",
|
||||
"+275760-09-30",
|
||||
"+275760-09-30T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.since(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04",
|
||||
"-271821-04-30",
|
||||
"-271821-04-30T23:59:59.999999999",
|
||||
"+275760-10",
|
||||
"+275760-10-01",
|
||||
"+275760-10-01T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`"${arg}" is outside the representable range of PlainYearMonth`
|
||||
);
|
||||
}
|
45
test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-limits.js
vendored
Normal file
45
test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
// 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.prototype.until
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(1970, 1);
|
||||
|
||||
// Note, these limits are different than other PlainYearMonth conversions
|
||||
// because the difference is taken between the first days of the two months, so
|
||||
// the first day of the month of the argument must be within the representable
|
||||
// range
|
||||
|
||||
const validStrings = [
|
||||
"-271821-05",
|
||||
"-271821-05-01",
|
||||
"-271821-05-01T00:00",
|
||||
"+275760-09",
|
||||
"+275760-09-30",
|
||||
"+275760-09-30T23:59:59.999999999",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.until(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04",
|
||||
"-271821-04-30",
|
||||
"-271821-04-30T23:59:59.999999999",
|
||||
"+275760-10",
|
||||
"+275760-10-01",
|
||||
"+275760-10-01T00:00",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`"${arg}" is outside the representable range of PlainYearMonth`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// 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.zoneddatetime.compare
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
Temporal.ZonedDateTime.compare(arg, instance);
|
||||
Temporal.ZonedDateTime.compare(instance, arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare(arg, instance),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare(instance, arg),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime (second argument)`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// offset: "use" takes the exact time with the given UTC offset, and so doesn't
|
||||
// need to compute the UTC epoch nanoseconds at the wall-clock time.
|
||||
// offset: "ignore" takes the UTC offset from the time zone, which in the case
|
||||
// of an offset time zone also doesn't need to compute the UTC epoch nanoseconds
|
||||
// at the wall-clock time.
|
||||
|
||||
const validStringsForOffsetUseIgnore = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const offset of ["use", "ignore"]) {
|
||||
for (const arg of validStringsForOffsetUseIgnore) {
|
||||
Temporal.ZonedDateTime.from(arg, { offset: "use" });
|
||||
}
|
||||
}
|
||||
|
||||
// Other values for offset need to compute the UTC epoch nanoseconds at the
|
||||
// wall-clock time, so that can't be outside the representable range even if
|
||||
// the signified exact time is inside.
|
||||
|
||||
const validStringsForOffsetPreferReject = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
const invalidStringsForOffsetPreferReject = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:00:01-23:59[-23:59]",
|
||||
];
|
||||
|
||||
for (const offset of ["prefer", "reject"]) {
|
||||
for (const arg of validStringsForOffsetPreferReject) {
|
||||
Temporal.ZonedDateTime.from(arg, { offset });
|
||||
}
|
||||
|
||||
for (const arg of invalidStringsForOffsetPreferReject) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.from(arg, { offset }),
|
||||
`wall-clock time of "${arg}" is outside the representable range of ZonedDateTime (offset=${offset})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const offset of ["use", "ignore", "prefer", "reject"]) {
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.from(arg, { offset }),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime (offset=${offset})`
|
||||
);
|
||||
}
|
||||
}
|
40
test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-limits.js
vendored
Normal file
40
test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
// 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.zoneddatetime.prototype.equals
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.equals(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals(arg),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime`
|
||||
);
|
||||
}
|
41
test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-limits.js
vendored
Normal file
41
test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// 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.zoneddatetime.prototype.since
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = "UTC";
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.since(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since(arg),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime`
|
||||
);
|
||||
}
|
41
test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-limits.js
vendored
Normal file
41
test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-limits.js
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// 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.zoneddatetime.prototype.until
|
||||
description: ISO strings at the edges of the representable range
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = "UTC";
|
||||
const instance = new Temporal.ZonedDateTime(0n, timeZone);
|
||||
|
||||
const validStrings = [
|
||||
"-271821-04-20T00:00Z[UTC]",
|
||||
"+275760-09-13T00:00Z[UTC]",
|
||||
"+275760-09-13T01:00+01:00[+01:00]",
|
||||
"+275760-09-13T23:59+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of validStrings) {
|
||||
instance.until(arg);
|
||||
}
|
||||
|
||||
const invalidStrings = [
|
||||
"-271821-04-19T23:00-01:00[-01:00]",
|
||||
"-271821-04-19T00:01-23:59[-23:59]",
|
||||
"-271821-04-19T23:59:59.999999999Z[UTC]",
|
||||
"-271821-04-19T23:00-00:59[-00:59]",
|
||||
"-271821-04-19T00:00:00-23:59[-23:59]",
|
||||
"+275760-09-13T00:00:00.000000001Z[UTC]",
|
||||
"+275760-09-13T01:00+00:59[+00:59]",
|
||||
"+275760-09-14T00:00+23:59[+23:59]",
|
||||
];
|
||||
|
||||
for (const arg of invalidStrings) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until(arg),
|
||||
`"${arg}" is outside the representable range of ZonedDateTime`
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue