mirror of
https://github.com/tc39/test262.git
synced 2025-07-03 12:14:37 +02:00
Temporal: Move remaining tests from Temporal/ZonedDateTime/old under staging into separate files under test/built-ins
Includes withPlainDateTime and withTimeZone
This commit is contained in:
parent
38d2924fb6
commit
7a4426e2b2
27
test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/basic.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/basic.js
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// 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.withplaintime
|
||||||
|
description: withPlainTime() works.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500[-08:00]");
|
||||||
|
|
||||||
|
// withPlainTime({ hour: 10 }) works
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(
|
||||||
|
zdt.withPlainTime({ hour: 10 }),
|
||||||
|
Temporal.ZonedDateTime.from("2015-12-07T10:00:00-08:00[-08:00]"));
|
||||||
|
|
||||||
|
// withPlainTime(time) works
|
||||||
|
const time = new Temporal.PlainTime(11, 22);
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(
|
||||||
|
zdt.withPlainTime(time),
|
||||||
|
Temporal.ZonedDateTime.from("2015-12-07T11:22:00-08:00[-08:00]"));
|
||||||
|
|
||||||
|
// withPlainTime('12:34') works
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(
|
||||||
|
zdt.withPlainTime("12:34"),
|
||||||
|
Temporal.ZonedDateTime.from( "2015-12-07T12:34:00-08:00[-08:00]"));
|
@ -0,0 +1,18 @@
|
|||||||
|
// 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.withplaintime
|
||||||
|
description: Incorrectly-spelled properties are ignored.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500[-08:00]");
|
||||||
|
|
||||||
|
TemporalHelpers.assertZonedDateTimesEqual(
|
||||||
|
zdt.withPlainTime({
|
||||||
|
hour: 10,
|
||||||
|
seconds: 55
|
||||||
|
}),
|
||||||
|
Temporal.ZonedDateTime.from("2015-12-07T10:00:00-08:00[-08:00]"));
|
22
test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/preserves-instant.js
vendored
Normal file
22
test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/preserves-instant.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.withtimezone
|
||||||
|
description: Keeps instant the same.
|
||||||
|
includes: [temporalHelpers.js]
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]");
|
||||||
|
const zdt2 = zdt.withTimeZone("-08:00");
|
||||||
|
|
||||||
|
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
|
||||||
|
assert.sameValue(zdt2.timeZoneId, "-08:00");
|
||||||
|
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
zdt.toPlainDateTime(),
|
||||||
|
2019, 11, "M11", 18, 15, 23, 30, 123, 456, 789);
|
||||||
|
TemporalHelpers.assertPlainDateTime(
|
||||||
|
zdt2.toPlainDateTime(),
|
||||||
|
2019, 11, "M11", 18, 6, 23, 30, 123, 456, 789);
|
@ -1,26 +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: .withPlainTime manipulation
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2015-12-07T03:24:30.000003500[-08:00]");
|
|
||||||
|
|
||||||
// withPlainTime({ hour: 10 }) works
|
|
||||||
assert.sameValue(`${ zdt.withPlainTime({ hour: 10 }) }`, "2015-12-07T10:00:00-08:00[-08:00]");
|
|
||||||
|
|
||||||
// withPlainTime(time) works
|
|
||||||
var time = Temporal.PlainTime.from("11:22");
|
|
||||||
assert.sameValue(`${ zdt.withPlainTime(time) }`, "2015-12-07T11:22:00-08:00[-08:00]");
|
|
||||||
|
|
||||||
// withPlainTime('12:34') works
|
|
||||||
assert.sameValue(`${ zdt.withPlainTime("12:34") }`, "2015-12-07T12:34:00-08:00[-08:00]");
|
|
||||||
|
|
||||||
// incorrectly-spelled properties are ignored
|
|
||||||
assert.sameValue(`${ zdt.withPlainTime({
|
|
||||||
hour: 10,
|
|
||||||
seconds: 55
|
|
||||||
}) }`, "2015-12-07T10:00:00-08:00[-08:00]");
|
|
@ -1,15 +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.withTimeZone()
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
// keeps instant the same
|
|
||||||
var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]");
|
|
||||||
var zdt2 = zdt.withTimeZone("-08:00");
|
|
||||||
assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds);
|
|
||||||
assert.sameValue(zdt2.timeZoneId, "-08:00");
|
|
||||||
assert.notSameValue(`${ zdt.toPlainDateTime() }`, `${ zdt2.toPlainDateTime() }`);
|
|
Loading…
x
Reference in New Issue
Block a user