-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: move tests for ZonedDateTime/p/{toInstant, toPlainDate, toP…
…lainTime, toString}
- Loading branch information
1 parent
7a4426e
commit 731468f
Showing
12 changed files
with
128 additions
and
73 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/recent-date.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-1.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-less-than-99.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/ZonedDateTime/prototype/toInstant/year-zero-leap-day.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 13 additions & 0 deletions
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/basic.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 13 additions & 0 deletions
13
test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/basic.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 12 additions & 0 deletions
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-auto.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 12 additions & 0 deletions
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset-never.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]"); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.