mirror of https://github.com/tc39/test262.git
Temporal: Add coverage for disallowed seconds in offset time zone identifiers
This was an area missing test coverage.
This commit is contained in:
parent
36f5cad9e0
commit
09c7d33253
|
@ -25,3 +25,6 @@ assert.sameValue(result, 0, "ISO string offset accepted with zero seconds (prope
|
|||
|
||||
relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone");
|
||||
|
||||
relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier");
|
||||
|
|
|
@ -25,3 +25,6 @@ TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "ISO string offset accept
|
|||
|
||||
relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone");
|
||||
|
||||
relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier");
|
||||
|
|
|
@ -24,3 +24,6 @@ assert.sameValue(result, 366, "ISO string offset accepted with zero seconds (pro
|
|||
|
||||
relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone");
|
||||
|
||||
relativeTo = "1970-01-01T00:00-00:44:59[-00:44:59]";
|
||||
assert.throws(RangeError, () => action(relativeTo), "sub-minute offset not accepted as time zone identifier");
|
||||
|
|
20
test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js
vendored
Normal file
20
test/built-ins/Temporal/Instant/prototype/toString/timezone-string-sub-minute-offset.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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.tostring
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toString({ timeZone }),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// 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.tozoneddatetimeiso
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toZonedDateTimeISO(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// 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.now.plaindateiso
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Now.plainDateISO(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// 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.now.plaindatetimeiso
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Now.plainDateTimeISO(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// 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.now.plaintimeiso
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Now.plainTimeISO(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
// 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.now.zoneddatetimeiso
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.Now.zonedDateTimeISO(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
20
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js
vendored
Normal file
20
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-sub-minute-offset.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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.tozoneddatetime
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(1970, 1, 1);
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.toZonedDateTime(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// 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: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(1588371240_000_000_000n, "+01:46");
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, instance),
|
||||
`${timeZone} is not a valid time zone string (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare(instance, { year: 2020, month: 5, day: 2, timeZone }),
|
||||
`${timeZone} is not a valid time zone string (second argument)`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// 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 cannot have sub-minute UTC offset as a time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(1588371240_000_000_000n, "+01:46");
|
||||
|
||||
const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]";
|
||||
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare(str, instance),
|
||||
`${str} is not a valid ISO string (first argument)`
|
||||
);
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.compare(instance, str),
|
||||
`${str} is not a valid ISO string (second argument)`
|
||||
);
|
|
@ -0,0 +1,18 @@
|
|||
// 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: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => Temporal.ZonedDateTime.from({ year: 2020, month: 5, day: 2, timeZone }),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
// 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 cannot have sub-minute UTC offset as a time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]";
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from(str), `${str} is not a valid ISO string`);
|
|
@ -0,0 +1,20 @@
|
|||
// 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: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.equals({ year: 2020, month: 5, day: 2, timeZone }),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
13
test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js
vendored
Normal file
13
test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-sub-minute-offset.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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 cannot have sub-minute UTC offset as a time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]";
|
||||
assert.throws(RangeError, () => instance.equals(str), `${str} is not a valid ISO string`);
|
|
@ -0,0 +1,20 @@
|
|||
// 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: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.since({ year: 2020, month: 5, day: 2, timeZone }),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
13
test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js
vendored
Normal file
13
test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-sub-minute-offset.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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 cannot have sub-minute UTC offset as a time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]";
|
||||
assert.throws(RangeError, () => instance.since(str), `${str} is not a valid ISO string`);
|
|
@ -0,0 +1,20 @@
|
|||
// 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: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.until({ year: 2020, month: 5, day: 2, timeZone }),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
13
test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js
vendored
Normal file
13
test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-sub-minute-offset.js
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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 cannot have sub-minute UTC offset as a time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
const str = "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]";
|
||||
assert.throws(RangeError, () => instance.until(str), `${str} is not a valid ISO string`);
|
|
@ -0,0 +1,20 @@
|
|||
// 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.withtimezone
|
||||
description: >
|
||||
Time zone parsing from ISO strings does not accept sub-minute UTC offset as
|
||||
time zone identifier
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
for (const timeZone of ["-12:12:59.9", "2021-08-19T17:30:45.123456789-12:12:59.9[-12:12:59.9]"]) {
|
||||
assert.throws(
|
||||
RangeError,
|
||||
() => instance.withTimeZone(timeZone),
|
||||
`${timeZone} is not a valid time zone string`
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue