mirror of https://github.com/tc39/test262.git
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.plainyearmonth.from
|
|
description: Properties on an object passed to from() are accessed in the correct order
|
|
includes: [compareArray.js, temporalHelpers.js]
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
const expected = [
|
|
"get calendar",
|
|
"get month",
|
|
"get month.valueOf",
|
|
"call month.valueOf",
|
|
"get monthCode",
|
|
"get monthCode.toString",
|
|
"call monthCode.toString",
|
|
"get year",
|
|
"get year.valueOf",
|
|
"call year.valueOf",
|
|
];
|
|
const actual = [];
|
|
const fields = {
|
|
year: 1.7,
|
|
month: 1.7,
|
|
monthCode: "M01",
|
|
};
|
|
const argument = new Proxy(fields, {
|
|
get(target, key) {
|
|
actual.push(`get ${key}`);
|
|
if (key === "calendar") return Temporal.Calendar.from("iso8601");
|
|
const result = target[key];
|
|
return TemporalHelpers.toPrimitiveObserver(actual, result, key);
|
|
},
|
|
has(target, key) {
|
|
actual.push(`has ${key}`);
|
|
return key in target;
|
|
},
|
|
});
|
|
const result = Temporal.PlainYearMonth.from(argument);
|
|
TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01");
|
|
assert.sameValue(result.calendar.id, "iso8601", "calendar result");
|
|
assert.compareArray(actual, expected, "order of operations");
|