Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainMonthDay/from/order-of-operations.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) 2020 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.plainmonthday.from
7 description: Properties on an object passed to from() are accessed in the correct order
8 includes: [compareArray.js, temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 const expectedOptionsReading = [
13 "get options.overflow",
14 "get options.overflow.toString",
15 "call options.overflow.toString",
16 ];
17
18 const expected = [
19 "get fields.calendar",
20 // PrepareTemporalFields
21 "get fields.day",
22 "get fields.day.valueOf",
23 "call fields.day.valueOf",
24 "get fields.month",
25 "get fields.month.valueOf",
26 "call fields.month.valueOf",
27 "get fields.monthCode",
28 "get fields.monthCode.toString",
29 "call fields.monthCode.toString",
30 "get fields.year",
31 "get fields.year.valueOf",
32 "call fields.year.valueOf",
33 ].concat(expectedOptionsReading);
34 const actual = [];
35
36 const fields = TemporalHelpers.propertyBagObserver(actual, {
37 year: 1.7,
38 month: 1.7,
39 monthCode: "M01",
40 day: 1.7,
41 calendar: "iso8601",
42 }, "fields", ["calendar"]);
43
44 const options = TemporalHelpers.propertyBagObserver(actual, {
45 overflow: "constrain",
46 extra: "property",
47 }, "options");
48
49 Temporal.PlainMonthDay.from(fields, options);
50 assert.compareArray(actual, expected, "order of operations");
51
52 actual.splice(0); // clear for next test
53
54 Temporal.PlainMonthDay.from(new Temporal.PlainMonthDay(5, 2), options);
55 assert.compareArray(actual, expectedOptionsReading, "order of operations when cloning a PlainMonthDay instance");
56
57 actual.splice(0);
58
59 Temporal.PlainMonthDay.from("05-02", options);
60 assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string");
61
62 reportCompare(0, 0);