mirror of
https://github.com/tc39/test262.git
synced 2025-11-13 02:09:47 +01:00
Temporal: Add tests for correct rounding of epoch milliseconds in toString()
This commit is contained in:
parent
18f6ed2627
commit
678c434dab
12
test/built-ins/Temporal/Instant/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
12
test/built-ins/Temporal/Instant/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.instant.prototype.tostring
|
||||||
|
description: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
|
||||||
|
features: [BigInt, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const instant = new Temporal.Instant(-1000000000000001000n);
|
||||||
|
assert.sameValue(instant.toString(), "1938-04-24T22:13:19.999999Z",
|
||||||
|
"epoch milliseconds should be rounded down to compute seconds");
|
||||||
12
test/built-ins/Temporal/PlainDateTime/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
12
test/built-ins/Temporal/PlainDateTime/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plaindatetime.prototype.tostring
|
||||||
|
description: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const pdt = new Temporal.PlainDateTime(1938, 4, 24, 22, 13, 19, 999, 999);
|
||||||
|
assert.sameValue(pdt.toString(), "1938-04-24T22:13:19.999999",
|
||||||
|
"epoch milliseconds should be rounded down to compute seconds");
|
||||||
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
12
test/built-ins/Temporal/ZonedDateTime/prototype/toString/fractionalseconddigits-negative.js
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Copyright (C) 2025 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: Epoch milliseconds should be rounded down before adding negative micro/nanoseconds back in
|
||||||
|
features: [BigInt, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const zdt = new Temporal.ZonedDateTime(-1000000000000001000n, "UTC");
|
||||||
|
assert.sameValue(zdt.toString(), "1938-04-24T22:13:19.999999+00:00[UTC]",
|
||||||
|
"epoch milliseconds should be rounded down to compute seconds");
|
||||||
Loading…
x
Reference in New Issue
Block a user