Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainYearMonth/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.plainyearmonth.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 // GetTemporalOverflowOption
14 "get options.overflow",
15 "get options.overflow.toString",
16 "call options.overflow.toString",
17 ];
18
19 const expected = [
20 // GetTemporalCalendarSlotValueWithISODefault
21 "get fields.calendar",
22 // PrepareTemporalFields
23 "get fields.month",
24 "get fields.month.valueOf",
25 "call fields.month.valueOf",
26 "get fields.monthCode",
27 "get fields.monthCode.toString",
28 "call fields.monthCode.toString",
29 "get fields.year",
30 "get fields.year.valueOf",
31 "call fields.year.valueOf",
32 ].concat(expectedOptionsReading);
33 const actual = [];
34
35 const fields = TemporalHelpers.propertyBagObserver(actual, {
36 year: 1.7,
37 month: 1.7,
38 monthCode: "M01",
39 calendar: "iso8601",
40 }, "fields", ["calendar"]);
41
42 const options = TemporalHelpers.propertyBagObserver(actual, {
43 overflow: "constrain",
44 extra: "property",
45 }, "options");
46
47 Temporal.PlainYearMonth.from(fields, options);
48 assert.compareArray(actual, expected, "order of operations");
49
50 actual.splice(0); // clear for next test
51
52 Temporal.PlainYearMonth.from(new Temporal.PlainYearMonth(2000, 5), options);
53 assert.compareArray(actual, expectedOptionsReading, "order of operations when cloning a PlainYearMonth instance");
54
55 actual.splice(0);
56
57 Temporal.PlainYearMonth.from("2000-05", options);
58 assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string");
59
60 reportCompare(0, 0);