Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Instant/basic.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.instant
7 description: Basic functionality of the Temporal.Instant constructor
8 features: [Temporal]
9 ---*/
10
11 const bigIntInstant = new Temporal.Instant(217175010123456789n);
12 assert(bigIntInstant instanceof Temporal.Instant, "BigInt instanceof");
13 assert.sameValue(bigIntInstant.epochMilliseconds, 217175010123, "BigInt epochMilliseconds");
14
15 const stringInstant = new Temporal.Instant("217175010123456789");
16 assert(stringInstant instanceof Temporal.Instant, "String instanceof");
17 assert.sameValue(stringInstant.epochMilliseconds, 217175010123, "String epochMilliseconds");
18
19 assert.throws(SyntaxError, () => new Temporal.Instant("abc123"), "invalid BigInt syntax");
20
21 reportCompare(0, 0);