mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Temporal: move tests for ZonedDateTime/p/{toInstant, toPlainDate, toPlainTime, toString}
This commit is contained in:
parent
7a4426e2b2
commit
bf46ed66b6
test
built-ins/Temporal/ZonedDateTime/prototype
toInstant
toPlainDate
toPlainTime
toString
staging/Temporal/ZonedDateTime/old
15
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js
vendored
Normal file
15
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toinstant
|
||||
description: toInstant() works with a recent date.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]");
|
||||
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("2019-10-29T09:46:38.271986102Z"));
|
25
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js
vendored
Normal file
25
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toinstant
|
||||
description: Year <= 1.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zdt = Temporal.ZonedDateTime.from("0000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0000-10-29T10:46:38.271986102Z"));
|
||||
|
||||
zdt = Temporal.ZonedDateTime.from("+000000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0000-10-29T10:46:38.271986102Z"));
|
||||
|
||||
zdt = Temporal.ZonedDateTime.from("-001000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("-001000-10-29T10:46:38.271986102Z"));
|
||||
|
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js
vendored
Normal file
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toinstant
|
||||
description: Year <= 99.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zdt = Temporal.ZonedDateTime.from("0098-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0098-10-29T10:46:38.271986102Z"));
|
||||
|
||||
zdt = Temporal.ZonedDateTime.from("+000098-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0098-10-29T10:46:38.271986102Z"));
|
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js
vendored
Normal file
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toinstant
|
||||
description: Year 0 leap day.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zdt = Temporal.ZonedDateTime.from("0000-02-29T00:00-00:01[-00:01]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0000-02-29T00:01:00Z"));
|
||||
|
||||
zdt = Temporal.ZonedDateTime.from("+000000-02-29T00:00-00:01[-00:01]");
|
||||
TemporalHelpers.assertInstantsEqual(
|
||||
zdt.toInstant(),
|
||||
Temporal.Instant.from("0000-02-29T00:01:00Z"));
|
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js
vendored
Normal file
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toplaindate
|
||||
description: toPlainDate() works as expected.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.ZonedDateTime.from("2019-10-29T09:46:38.271986102[-07:00]");
|
||||
|
||||
TemporalHelpers.assertPlainDate(zdt.toPlainDate(), 2019, 10, "M10", 29);
|
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js
vendored
Normal file
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.toplaintime
|
||||
description: toPlainTime() works as expected.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = Temporal.ZonedDateTime.from("2019-10-29T09:46:38.271986102Z[-07:00]");
|
||||
|
||||
TemporalHelpers.assertPlainTime(zdt.toPlainTime(), 2, 46, 38, 271, 986, 102);
|
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js
vendored
Normal file
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.tostring
|
||||
description: Shows offset if offset = auto.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]");
|
||||
|
||||
assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]");
|
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js
vendored
Normal file
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.tostring
|
||||
description: Omits offset if offset = never.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]");
|
||||
|
||||
assert.sameValue(zdt1.toString({ offset: "never" }), "1976-11-18T15:23:00[UTC]");
|
@ -1,33 +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: Temporal.ZonedDateTime.prototype.toInstant()
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
|
||||
// recent date
|
||||
var zdt = Temporal.ZonedDateTime.from("2019-10-29T10:46:38.271986102+01:00[+01:00]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "2019-10-29T09:46:38.271986102Z");
|
||||
|
||||
// year ≤ 99
|
||||
var zdt = Temporal.ZonedDateTime.from("0098-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0098-10-29T10:46:38.271986102Z");
|
||||
zdt = Temporal.ZonedDateTime.from("+000098-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0098-10-29T10:46:38.271986102Z");
|
||||
|
||||
// year < 1
|
||||
var zdt = Temporal.ZonedDateTime.from("0000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0000-10-29T10:46:38.271986102Z");
|
||||
zdt = Temporal.ZonedDateTime.from("+000000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0000-10-29T10:46:38.271986102Z");
|
||||
zdt = Temporal.ZonedDateTime.from("-001000-10-29T10:46:38.271986102+00:00[UTC]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "-001000-10-29T10:46:38.271986102Z");
|
||||
|
||||
// year 0 leap day
|
||||
var zdt = Temporal.ZonedDateTime.from("0000-02-29T00:00-00:01[-00:01]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:00Z");
|
||||
zdt = Temporal.ZonedDateTime.from("+000000-02-29T00:00-00:01[-00:01]");
|
||||
assert.sameValue(`${ zdt.toInstant() }`, "0000-02-29T00:01:00Z");
|
@ -1,12 +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: Temporal.ZonedDateTime.prototype.toPlainDate()
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// works
|
||||
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00");
|
||||
assert.sameValue(`${ zdt.toPlainDate() }`, "2019-10-29");
|
@ -1,12 +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: Temporal.ZonedDateTime.prototype.toPlainTime()
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
// works
|
||||
var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00");
|
||||
assert.sameValue(`${ zdt.toPlainTime() }`, "02:46:38.271986102");
|
@ -1,16 +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: Temporal.ZonedDateTime.prototype.toString()
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]");
|
||||
|
||||
// shows offset if offset = auto
|
||||
assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]");
|
||||
|
||||
// omits offset if offset = never
|
||||
assert.sameValue(zdt1.toString({ offset: "never" }), "1976-11-18T15:23:00[UTC]");
|
Loading…
x
Reference in New Issue
Block a user