// 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.plaindate.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 day", "get day.valueOf", "call day.valueOf", "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", day: 1.7, }; 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.PlainDate.from(argument); TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1); assert.sameValue(result.calendar.id, "iso8601", "calendar result"); assert.compareArray(actual, expected, "order of operations");