Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Instant/from/argument-object-tostring.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) 2022 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.from
7 description: Object is converted to a string, then to Temporal.Instant
8 features: [Temporal]
9 ---*/
10
11 const arg = {};
12 assert.throws(RangeError, () => Temporal.Instant.from(arg), "[object Object] is not a valid ISO string");
13
14 arg.toString = function() {
15 return "1970-01-01T00:00Z";
16 };
17 const result = Temporal.Instant.from(arg);
18 assert.sameValue(result.epochNanoseconds, 0n, "result of toString is interpreted as ISO string");
19
20 reportCompare(0, 0);