node/deps/v8/test/mjsunit/temporal/instant-from-epoch-seconds.js
Michaël Zasso 6bd756d7c6
deps: update V8 to 10.7.193.13
PR-URL: https://github.com/nodejs/node/pull/44741
Fixes: https://github.com/nodejs/node/issues/44650
Fixes: https://github.com/nodejs/node/issues/37472
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-11 07:24:33 +02:00

31 lines
999 B
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-temporal
let bigint_nano = 7890123456789000000000n;
let sec = 7890123456789;
let bigint_sec = BigInt(sec);
let inst1 = new Temporal.Instant(bigint_nano);
assertThrows(() =>
Temporal.Instant.fromEpochSeconds(bigint_sec),
TypeError)
let inst2 = Temporal.Instant.fromEpochSeconds(sec);
assertEquals(inst1, inst2);
let just_fit_neg = -8640000000000;
let just_fit_pos = 8640000000000;
let too_big = 8640000000001;
let too_small = -8640000000001;
assertThrows(() =>
Temporal.Instant.fromEpochSeconds(too_small),
RangeError)
assertThrows(() =>
Temporal.Instant.fromEpochSeconds(too_big),
RangeError)
assertEquals(just_fit_neg,
(Temporal.Instant.fromEpochSeconds(just_fit_neg)).epochSeconds);
assertEquals(just_fit_pos,
(Temporal.Instant.fromEpochSeconds(just_fit_pos)).epochSeconds);