-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Extend toJSON/toString tests.
- Loading branch information
Showing
12 changed files
with
95 additions
and
51 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
// Copyright (C) 2020 Igalia, S.L. All rights reserved. | ||
// 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.tojson | ||
description: Basic tests for toJSON() | ||
features: [Temporal] | ||
description: Basic behavior for toJSON | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const instantBeforeEpoch = Temporal.Instant.from("1963-02-13T10:36:29.123456789+01:00"); | ||
assert.sameValue(instantBeforeEpoch.toJSON(), "1963-02-13T09:36:29.123456789Z"); | ||
const tests = [ | ||
[new Temporal.Instant(192_258_181_000_000_000n), "1976-02-04T05:03:01Z"], | ||
[new Temporal.Instant(0n), "1970-01-01T00:00:00Z"], | ||
[new Temporal.Instant(30_000_000_000n), "1970-01-01T00:00:30Z"], | ||
[new Temporal.Instant(30_123_400_000n), "1970-01-01T00:00:30.1234Z"], | ||
]; | ||
|
||
const instantAfterEpoch = Temporal.Instant.from("1976-11-18T15:23:30.123456789+01:00"); | ||
assert.sameValue(instantAfterEpoch.toJSON(), "1976-11-18T14:23:30.123456789Z"); | ||
assert.sameValue(instantAfterEpoch.toJSON("+01:00"), "1976-11-18T14:23:30.123456789Z", | ||
"after epoch with ignored argument"); | ||
const options = new Proxy({}, { | ||
get() { throw new Test262Error("should not get properties off argument") } | ||
}); | ||
for (const [instant, expected] of tests) { | ||
assert.sameValue(instant.toJSON(), expected, "toJSON without argument"); | ||
assert.sameValue(instant.toJSON(options), expected, "toJSON with argument"); | ||
} |
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
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
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
23 changes: 23 additions & 0 deletions
23
test/built-ins/Temporal/PlainDateTime/prototype/toJSON/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,23 @@ | ||
// 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.plaindatetime.prototype.tojson | ||
description: Basic behavior for toJSON | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
[new Temporal.PlainDateTime(1976, 2, 4, 5, 3, 1), "1976-02-04T05:03:01"], | ||
[new Temporal.PlainDateTime(1976, 11, 18, 15, 23), "1976-11-18T15:23:00"], | ||
[new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30), "1976-11-18T15:23:30"], | ||
[new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 400), "1976-11-18T15:23:30.1234"], | ||
]; | ||
|
||
const options = new Proxy({}, { | ||
get() { throw new Test262Error("should not get properties off argument") } | ||
}); | ||
for (const [datetime, expected] of tests) { | ||
assert.sameValue(datetime.toJSON(), expected, "toJSON without argument"); | ||
assert.sameValue(datetime.toJSON(options), expected, "toJSON with argument"); | ||
} |
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
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
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
23 changes: 23 additions & 0 deletions
23
test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/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,23 @@ | ||
// 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.prototype.tojson | ||
description: Basic behavior for toJSON | ||
features: [BigInt, Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
[new Temporal.ZonedDateTime(192_258_181_000_000_000n, "UTC"), "1976-02-04T05:03:01+00:00[UTC]"], | ||
[new Temporal.ZonedDateTime(0n, "UTC"), "1970-01-01T00:00:00+00:00[UTC]"], | ||
[new Temporal.ZonedDateTime(30_000_000_000n, "UTC"), "1970-01-01T00:00:30+00:00[UTC]"], | ||
[new Temporal.ZonedDateTime(30_123_400_000n, "UTC"), "1970-01-01T00:00:30.1234+00:00[UTC]"], | ||
]; | ||
|
||
const options = new Proxy({}, { | ||
get() { throw new Test262Error("should not get properties off argument") } | ||
}); | ||
for (const [datetime, expected] of tests) { | ||
assert.sameValue(datetime.toJSON(), expected, "toJSON without argument"); | ||
assert.sameValue(datetime.toJSON(options), expected, "toJSON with argument"); | ||
} |
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
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
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