mirror of https://github.com/tc39/test262.git
Temporal: Split up ZonedDateTime/old/string-parsing.js and move out of staging
This commit is contained in:
parent
8cc0560713
commit
ccf8977b1c
|
@ -0,0 +1,28 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Mixture of basic and extended format.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
[
|
||||
"1976-11-18T152330.1-08:00[-08:00]",
|
||||
"19761118T15:23:30.1-08:00[-08:00]",
|
||||
"1976-11-18T15:23:30.1-0800[-08:00]",
|
||||
"1976-11-18T152330.1-0800[-08:00]",
|
||||
"19761118T15:23:30.1-0800[-08:00]",
|
||||
"19761118T152330.1-08:00[-08:00]",
|
||||
"19761118T152330.1-0800[-08:00]",
|
||||
"+001976-11-18T152330.1-08:00[-08:00]",
|
||||
"+0019761118T15:23:30.1-08:00[-08:00]",
|
||||
"+001976-11-18T15:23:30.1-0800[-08:00]",
|
||||
"+001976-11-18T152330.1-0800[-08:00]",
|
||||
"+0019761118T15:23:30.1-0800[-08:00]",
|
||||
"+0019761118T152330.1-08:00[-08:00]",
|
||||
"+0019761118T152330.1-0800[-08:00]"
|
||||
].forEach(input => TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from(input),
|
||||
new Temporal.ZonedDateTime(217207410100000000n, "-08:00")));
|
|
@ -0,0 +1,37 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: from() can parse any number of decimal places
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410100000000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410120000000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123000000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1234-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123400000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12345-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123450000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123456000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1234567-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123456700n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12345678-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123456780n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410123456789n, "-08:00"));
|
|
@ -0,0 +1,13 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Can parse negative extended year
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("-009999-11-18T15:23:30.12+00:00[UTC]"),
|
||||
new Temporal.ZonedDateTime(-377677326989880000000n, "UTC"));
|
|
@ -0,0 +1,11 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: No junk at end of string.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789-08:00[-08:00]junk"))
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Optional parts.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30-08[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410000000000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217206000000000000n, "-08:00"));
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("2020-01-01[+09:00]"),
|
||||
new Temporal.ZonedDateTime(1577804400000000000n, "+09:00"));
|
|
@ -0,0 +1,13 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Can parse variant decimal separator.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
TemporalHelpers.assertZonedDateTimesEqual(
|
||||
Temporal.ZonedDateTime.from("1976-11-18T15:23:30,12-08:00[-08:00]"),
|
||||
new Temporal.ZonedDateTime(217207410120000000n, "-08:00"));
|
|
@ -0,0 +1,16 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Throw on bad value for disambiguation
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
[
|
||||
"",
|
||||
"EARLIER",
|
||||
"balance"
|
||||
].forEach(disambiguation => {
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-11-01T04:00[-08:00]", { disambiguation }));
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: Constrain overflow option has no effect on invalid ISO string.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-13-34T24:60[-08:00]", { overflow: "constrain" }));
|
|
@ -18,3 +18,5 @@ const obj = {
|
|||
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj));
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { offset: "reject" }));
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-03-08T01:00-04:00[UTC]"));
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-03-08T01:00-04:00[UTC]", { offset: "reject" }));
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (C) 2018 Bloomberg LP. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal-zoneddatetime-objects
|
||||
description: string parsing
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// any number of decimal places
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1-08:00[-08:00]") }`, "1976-11-18T15:23:30.1-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12-08:00[-08:00]") }`, "1976-11-18T15:23:30.12-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123-08:00[-08:00]") }`, "1976-11-18T15:23:30.123-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1234-08:00[-08:00]") }`, "1976-11-18T15:23:30.1234-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12345-08:00[-08:00]") }`, "1976-11-18T15:23:30.12345-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456-08:00[-08:00]") }`, "1976-11-18T15:23:30.123456-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.1234567-08:00[-08:00]") }`, "1976-11-18T15:23:30.1234567-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.12345678-08:00[-08:00]") }`, "1976-11-18T15:23:30.12345678-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789-08:00[-08:00]") }`, "1976-11-18T15:23:30.123456789-08:00[-08:00]");
|
||||
|
||||
// variant decimal separator
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30,12-08:00[-08:00]") }`, "1976-11-18T15:23:30.12-08:00[-08:00]");
|
||||
|
||||
// negative extended year
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("-009999-11-18T15:23:30.12+00:00[UTC]") }`, "-009999-11-18T15:23:30.12+00:00[UTC]");
|
||||
|
||||
// mixture of basic and extended format
|
||||
[
|
||||
"1976-11-18T152330.1-08:00[-08:00]",
|
||||
"19761118T15:23:30.1-08:00[-08:00]",
|
||||
"1976-11-18T15:23:30.1-0800[-08:00]",
|
||||
"1976-11-18T152330.1-0800[-08:00]",
|
||||
"19761118T15:23:30.1-0800[-08:00]",
|
||||
"19761118T152330.1-08:00[-08:00]",
|
||||
"19761118T152330.1-0800[-08:00]",
|
||||
"+001976-11-18T152330.1-08:00[-08:00]",
|
||||
"+0019761118T15:23:30.1-08:00[-08:00]",
|
||||
"+001976-11-18T15:23:30.1-0800[-08:00]",
|
||||
"+001976-11-18T152330.1-0800[-08:00]",
|
||||
"+0019761118T15:23:30.1-0800[-08:00]",
|
||||
"+0019761118T152330.1-08:00[-08:00]",
|
||||
"+0019761118T152330.1-0800[-08:00]"
|
||||
].forEach(input => assert.sameValue(`${ Temporal.ZonedDateTime.from(input) }`, "1976-11-18T15:23:30.1-08:00[-08:00]"));
|
||||
|
||||
// optional parts
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15:23:30-08[-08:00]") }`, "1976-11-18T15:23:30-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("1976-11-18T15-08:00[-08:00]") }`, "1976-11-18T15:00:00-08:00[-08:00]");
|
||||
assert.sameValue(`${ Temporal.ZonedDateTime.from("2020-01-01[+09:00]") }`, "2020-01-01T00:00:00+09:00[+09:00]");
|
||||
|
||||
// no junk at end of string
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("1976-11-18T15:23:30.123456789-08:00[-08:00]junk"))
|
||||
|
||||
// constrain has no effect on invalid ISO string
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-13-34T24:60[-08:00]", { overflow: "constrain" }));
|
||||
|
||||
// { offset: 'reject' } throws if offset does not match IANA time zone
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-03-08T01:00-04:00[UTC]"));
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-03-08T01:00-04:00[UTC]", { offset: "reject" }));
|
||||
|
||||
// throw when bad disambiguation
|
||||
[
|
||||
"",
|
||||
"EARLIER",
|
||||
"balance"
|
||||
].forEach(disambiguation => {
|
||||
assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-11-01T04:00[-08:00]", { disambiguation }));
|
||||
});
|
Loading…
Reference in New Issue