From d28ca991cb634a7eec71ea87be75de1c7f5f4633 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Thu, 14 Apr 2022 17:39:34 -0700 Subject: [PATCH] Test conversion of Temporal.Instant strings with sub-minute UTC offsets --- .../compare/instant-string-sub-minute-offset.js | 17 +++++++++++++++++ .../from/instant-string-sub-minute-offset.js | 12 ++++++++++++ .../equals/instant-string-sub-minute-offset.js | 14 ++++++++++++++ .../since/instant-string-sub-minute-offset.js | 15 +++++++++++++++ .../until/instant-string-sub-minute-offset.js | 15 +++++++++++++++ .../instant-string-sub-minute-offset.js | 15 +++++++++++++++ 6 files changed, 88 insertions(+) create mode 100644 test/built-ins/Temporal/Instant/compare/instant-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Instant/from/instant-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Instant/prototype/equals/instant-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/instant-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/instant-string-sub-minute-offset.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js diff --git a/test/built-ins/Temporal/Instant/compare/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/compare/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..8b44cd75d0 --- /dev/null +++ b/test/built-ins/Temporal/Instant/compare/instant-string-sub-minute-offset.js @@ -0,0 +1,17 @@ +// 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: Temporal.Instant string with sub-minute offset +features: [Temporal] +---*/ + +const epoch = new Temporal.Instant(0n); +const str = "1970-01-01T00:19:32.37+00:19:32.37"; + +const result1 = Temporal.Instant.compare(str, epoch); +assert.sameValue(result1, 0, "if present, sub-minute offset is accepted exactly (first argument)"); + +const result2 = Temporal.Instant.compare(epoch, str); +assert.sameValue(result2, 0, "if present, sub-minute offset is accepted exactly (second argument)"); diff --git a/test/built-ins/Temporal/Instant/from/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/from/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..70c3f19870 --- /dev/null +++ b/test/built-ins/Temporal/Instant/from/instant-string-sub-minute-offset.js @@ -0,0 +1,12 @@ +// 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: Temporal.Instant string with sub-minute offset +features: [Temporal] +---*/ + +const str = "1970-01-01T00:19:32.37+00:19:32.37"; +const result = Temporal.Instant.from(str); +assert.sameValue(result.epochNanoseconds, 0n, "if present, sub-minute offset is accepted exactly"); diff --git a/test/built-ins/Temporal/Instant/prototype/equals/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/prototype/equals/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..5bbaaf32c4 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/equals/instant-string-sub-minute-offset.js @@ -0,0 +1,14 @@ +// 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: Temporal.Instant string with sub-minute offset +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const str = "1970-01-01T00:19:32.37+00:19:32.37"; +const result = instance.equals(str); +assert.sameValue(result, true, "if present, sub-minute offset is accepted exactly"); diff --git a/test/built-ins/Temporal/Instant/prototype/since/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/prototype/since/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..00e766024f --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/instant-string-sub-minute-offset.js @@ -0,0 +1,15 @@ +// 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: Temporal.Instant string with sub-minute offset +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const str = "1970-01-01T00:19:32.37+00:19:32.37"; +const result = instance.since(str); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly"); diff --git a/test/built-ins/Temporal/Instant/prototype/until/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/Instant/prototype/until/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..9630b1a4f0 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/instant-string-sub-minute-offset.js @@ -0,0 +1,15 @@ +// 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: Temporal.Instant string with sub-minute offset +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); + +const str = "1970-01-01T00:19:32.37+00:19:32.37"; +const result = instance.until(str); +TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js new file mode 100644 index 0000000000..766cec0863 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js @@ -0,0 +1,15 @@ +// 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.timezone.prototype.getplaindatetimefor +description: Temporal.Instant string with sub-minute offset +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.TimeZone("UTC"); + +const str = "1970-01-01T00:19:32.37+00:19:32.37"; +const result = instance.getPlainDateTimeFor(str); +TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly");