From a5eaadfb43d425d0bcdb8bc4d642ee8c38f52e3e Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 24 Nov 2025 10:41:16 -0800 Subject: [PATCH] Temporal: Add order-of-operations tests for toPlainDate Add order-of-operations tests for toPlainDate for PlainMonthDay and PlainYearMonth --- .../toPlainDate/order-of-operations.js | 29 +++++++++++++++++++ .../toPlainDate/order-of-operations.js | 29 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/order-of-operations.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/order-of-operations.js diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/order-of-operations.js new file mode 100644 index 0000000000..416b5bfa86 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/order-of-operations.js @@ -0,0 +1,29 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.toplaindate +description: Properties on an object passed to toPlainDate() are accessed in the correct order +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "get fields.year", + "get fields.year.valueOf", + "call fields.year.valueOf", +]; +const actual = []; + +const fields = TemporalHelpers.propertyBagObserver(actual, { + year: 1.7, + month: 1.7, + monthCode: "M01", + day: 1.7, + calendar: "iso8601", +}, "fields", ["calendar"]); + +const pmd = new Temporal.PlainMonthDay(5, 2); + +pmd.toPlainDate(fields); +assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/order-of-operations.js new file mode 100644 index 0000000000..8e8ba5f255 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/order-of-operations.js @@ -0,0 +1,29 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.toplaindate +description: Properties on an object passed to toPlainDate() are accessed in the correct order +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "get fields.day", + "get fields.day.valueOf", + "call fields.day.valueOf", +]; +const actual = []; + +const fields = TemporalHelpers.propertyBagObserver(actual, { + year: 1.7, + month: 1.7, + monthCode: "M01", + day: 1, + calendar: "iso8601", +}, "fields", ["calendar"]); + +const pym = new Temporal.PlainYearMonth(2005, 2); + +pym.toPlainDate(fields); +assert.compareArray(actual, expected, "order of operations");