2021-10-10 11:10:43 +02:00
|
|
|
// 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 = 567890123456789000000n;
|
2022-09-21 13:28:42 +02:00
|
|
|
let milli = 567890123456789;
|
|
|
|
let bigint_milli = BigInt(milli);
|
2021-10-10 11:10:43 +02:00
|
|
|
let inst1 = new Temporal.Instant(bigint_nano);
|
2022-09-21 13:28:42 +02:00
|
|
|
assertThrows(() =>
|
|
|
|
Temporal.Instant.fromEpochMilliseconds(bigint_milli),
|
|
|
|
TypeError);
|
|
|
|
let inst2 = Temporal.Instant.fromEpochMilliseconds(milli);
|
2021-10-10 11:10:43 +02:00
|
|
|
assertEquals(inst1, inst2);
|
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
let just_fit_neg = -8640000000000000;
|
|
|
|
let just_fit_pos = 8640000000000000;
|
|
|
|
let too_big = 8640000000000001;
|
|
|
|
let too_small = -8640000000000001;
|
2021-10-10 11:10:43 +02:00
|
|
|
|
|
|
|
assertThrows(() =>
|
2022-09-21 13:28:42 +02:00
|
|
|
Temporal.Instant.fromEpochMilliseconds(too_small),
|
2021-10-10 11:10:43 +02:00
|
|
|
RangeError);
|
|
|
|
assertThrows(() =>
|
2022-09-21 13:28:42 +02:00
|
|
|
Temporal.Instant.fromEpochMilliseconds(too_big),
|
2021-10-10 11:10:43 +02:00
|
|
|
RangeError);
|
2022-09-21 13:28:42 +02:00
|
|
|
assertEquals(just_fit_neg,
|
2021-10-10 11:10:43 +02:00
|
|
|
(Temporal.Instant.fromEpochMilliseconds(
|
2022-09-21 13:28:42 +02:00
|
|
|
just_fit_neg)).epochMilliseconds);
|
|
|
|
assertEquals(just_fit_pos,
|
2021-10-10 11:10:43 +02:00
|
|
|
(Temporal.Instant.fromEpochMilliseconds(
|
2022-09-21 13:28:42 +02:00
|
|
|
just_fit_pos)).epochMilliseconds);
|