Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-slots.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.plaindate.from
7 description: Getters are not called when converting a ZonedDateTime to a PlainDate.
8 includes: [compareArray.js]
9 features: [Temporal]
10 ---*/
11
12 const actual = [];
13 const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype);
14 const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"];
15
16 for (const property of getters) {
17 Object.defineProperty(Temporal.ZonedDateTime.prototype, property, {
18 get() {
19 actual.push(`get ${property}`);
20 const value = prototypeDescrs[property].get.call(this);
21 return {
22 toString() {
23 actual.push(`toString ${property}`);
24 return value.toString();
25 },
26 valueOf() {
27 actual.push(`valueOf ${property}`);
28 return value;
29 },
30 };
31 },
32 });
33 }
34
35 const arg = new Temporal.ZonedDateTime(0n, "UTC");
36 Temporal.PlainDate.from(arg);
37 assert.compareArray(actual, []);
38
39 reportCompare(0, 0);