summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with')
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/basic.js44
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/branding.js27
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js23
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js46
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin.js36
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js36
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js32
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js18
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js21
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js18
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js16
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js34
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copy-properties-not-undefined.js25
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js18
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/infinity-throws-rangeerror.js25
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/length.js28
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/name.js26
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/not-a-constructor.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-invalid.js16
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js26
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-undefined.js20
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js26
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js76
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-invalid-string.js31
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-undefined.js29
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-wrong-type.js27
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/prop-desc.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js16
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/subclassing-ignored.js20
31 files changed, 832 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/basic.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/basic.js
new file mode 100644
index 0000000000..27f4069fc4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/basic.js
@@ -0,0 +1,44 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Basic tests for with().
+includes: [compareArray.js, temporalHelpers.js]
+features: [Symbol, Temporal]
+---*/
+
+const md = Temporal.PlainMonthDay.from("01-15");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ day: 22 }),
+ "M01", 22, "with({day})");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ month: 12 }),
+ "M12", 15, "with({month})");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ monthCode: "M12" }),
+ "M12", 15, "with({monthCode})");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ month: 12, monthCode: "M12" }),
+ "M12", 15, "with({month, monthCode}) agree");
+
+assert.throws(RangeError, () => md.with({ month: 12, monthCode: "M11" }), "with({month, monthCode}) disagree");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ year: 2000, month: 12 }),
+ "M12", 15, "with({year, month})");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ year: 2000 }),
+ "M01", 15, "with({year})");
+
+assert.throws(TypeError, () => md.with({ day: 1, calendar: "iso8601" }), "with({calendar})");
+
+assert.throws(TypeError, () => md.with({ day: 1, timeZone: "UTC" }), "with({timeZone})");
+
+assert.throws(TypeError, () => md.with({}), "with({})");
+assert.throws(TypeError, () => md.with({ months: 12 }), "with({months})");
+
+TemporalHelpers.assertPlainMonthDay(md.with({ monthCode: "M12", days: 1 }),
+ "M12", 15, "with({monthCode, days})");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/branding.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/branding.js
new file mode 100644
index 0000000000..1df04554e4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/branding.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Throw a TypeError if the receiver is invalid
+features: [Symbol, Temporal]
+---*/
+
+const with_ = Temporal.PlainMonthDay.prototype.with;
+
+assert.sameValue(typeof with_, "function");
+
+const args = [{ year: 2022, month: 12 }];
+
+assert.throws(TypeError, () => with_.apply(undefined, args), "undefined");
+assert.throws(TypeError, () => with_.apply(null, args), "null");
+assert.throws(TypeError, () => with_.apply(true, args), "true");
+assert.throws(TypeError, () => with_.apply("", args), "empty string");
+assert.throws(TypeError, () => with_.apply(Symbol(), args), "symbol");
+assert.throws(TypeError, () => with_.apply(1, args), "1");
+assert.throws(TypeError, () => with_.apply({}, args), "plain object");
+assert.throws(TypeError, () => with_.apply(Temporal.PlainMonthDay, args), "Temporal.PlainMonthDay");
+assert.throws(TypeError, () => with_.apply(Temporal.PlainMonthDay.prototype, args), "Temporal.PlainMonthDay.prototype");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/browser.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/browser.js
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js
new file mode 100644
index 0000000000..10936aca0b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js
@@ -0,0 +1,23 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Calling the method on an instance constructed with a builtin calendar causes
+ no observable array iteration when getting the calendar fields.
+features: [Temporal]
+---*/
+
+const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator];
+Array.prototype[Symbol.iterator] = function arrayIterator() {
+ throw new Test262Error("Array should not be iterated");
+}
+
+const instance = new Temporal.PlainMonthDay(5, 1, "iso8601");
+instance.with({ monthCode: "M04" });
+
+Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal;
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js
new file mode 100644
index 0000000000..5b4469a1d8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js
@@ -0,0 +1,46 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Calling the method on an instance constructed with a builtin calendar causes
+ no observable lookups or calls to calendar methods.
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields");
+Object.defineProperty(Temporal.Calendar.prototype, "fields", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("fields should not be looked up");
+ },
+});
+const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields");
+Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("mergeFields should not be looked up");
+ },
+});
+const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields");
+Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up");
+ },
+});
+
+const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972);
+instance.with({ monthCode: "M06" });
+
+Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal);
+Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal);
+Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin.js
new file mode 100644
index 0000000000..a94e0fd066
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/builtin.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Tests that Temporal.PlainMonthDay.prototype.with
+ meets the requirements for built-in objects defined by the
+ introduction of chapter 17 of the ECMAScript Language Specification.
+info: |
+ Built-in functions that are not constructors do not have a "prototype" property unless
+ otherwise specified in the description of a particular function.
+
+ Unless specified otherwise, a built-in object that is callable as a function is a built-in
+ function object with the characteristics described in 10.3. Unless specified otherwise, the
+ [[Extensible]] internal slot of a built-in object initially has the value true.
+
+ Unless otherwise specified every built-in function and every built-in constructor has the
+ Function prototype object [...] as the value of its [[Prototype]] internal slot.
+features: [Temporal]
+---*/
+
+assert.sameValue(Object.isExtensible(Temporal.PlainMonthDay.prototype.with),
+ true, "Built-in objects must be extensible.");
+
+assert.sameValue(Object.prototype.toString.call(Temporal.PlainMonthDay.prototype.with),
+ "[object Function]", "Object.prototype.toString");
+
+assert.sameValue(Object.getPrototypeOf(Temporal.PlainMonthDay.prototype.with),
+ Function.prototype, "prototype");
+
+assert.sameValue(Temporal.PlainMonthDay.prototype.with.hasOwnProperty("prototype"),
+ false, "prototype property");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js
new file mode 100644
index 0000000000..5f98ed2e34
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js
@@ -0,0 +1,36 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Correct options value is passed to calendar method
+info: |
+ MonthDayFromFields ( calendar, fields [ , options ] )
+
+ 5. Let monthDay be ? Invoke(calendar, "monthDayFromFields", « fields, options »).
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const options = {
+ extra: "property",
+};
+class CustomCalendar extends Temporal.Calendar {
+ constructor() {
+ super("iso8601");
+ }
+ monthDayFromFields(...args) {
+ assert.sameValue(args.length, 2, "args.length");
+ assert.sameValue(typeof args[0], "object", "args[0]");
+ assert.notSameValue(args[1], options, "args[1] is a copy of options");
+ assert.sameValue(args[1].extra, "property", "All properties are copied");
+ assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype");
+ return super.monthDayFromFields(...args);
+ }
+}
+const plainMonthDay = new Temporal.PlainMonthDay(7, 2, new CustomCalendar());
+const result = plainMonthDay.with({ monthCode: "M05" }, options);
+TemporalHelpers.assertPlainMonthDay(result, "M05", 2);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js
new file mode 100644
index 0000000000..6d944a6cf7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js
@@ -0,0 +1,32 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Verify the result of calendar.fields() is treated correctly.
+info: |
+ sec-temporal.plainmonthday.prototype.with step 9:
+ 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »).
+ sec-temporal-calendarfields step 4:
+ 4. Let _result_ be ? IterableToList(_fieldsArray_).
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const expected = [
+ "day",
+ "month",
+ "monthCode",
+ "year",
+];
+
+const calendar = TemporalHelpers.calendarFieldsIterable();
+const monthday = new Temporal.PlainMonthDay(5, 2, calendar);
+monthday.with({ day: 6 });
+
+assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once");
+assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args");
+assert(calendar.iteratorExhausted[0], "iterated through the whole iterable");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js
new file mode 100644
index 0000000000..f7f5b57d89
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Calendar.monthDayFromFields method is called with a null-prototype fields object
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution();
+const instance = new Temporal.PlainMonthDay(5, 2, calendar);
+instance.with({ day: 24 });
+assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should have been called on the calendar");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js
new file mode 100644
index 0000000000..c181271486
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js
@@ -0,0 +1,21 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ with() should throw a TypeError if mergeFields() returns a primitive,
+ without passing the value on to any other calendar methods
+includes: [compareArray.js, temporalHelpers.js]
+features: [BigInt, Symbol, Temporal]
+---*/
+
+[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => {
+ const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive);
+ const instance = new Temporal.PlainMonthDay(5, 2, calendar);
+ assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws");
+ assert.sameValue(calendar.monthDayFromFieldsCallCount, 0, "monthDayFromFields() never called");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js
new file mode 100644
index 0000000000..a91186566a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Calendar.mergeFields method is called with null-prototype fields objects
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution();
+const instance = new Temporal.PlainMonthDay(5, 2, calendar);
+instance.with({ day: 24 });
+assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js
new file mode 100644
index 0000000000..6d56671dde
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError.
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']);
+const md = new Temporal.PlainMonthDay(5, 1, calendar);
+
+assert.throws(RangeError, () => md.with({day: 15}));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js
new file mode 100644
index 0000000000..36b0941bb1
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js
@@ -0,0 +1,34 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: The object returned from mergeFields() is copied before being passed to monthDayFromFields().
+info: |
+ sec-temporal.plainmonthday.prototype.with steps 13–15:
+ 13. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialMonthDay_).
+ 14. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»).
+ 15. Return ? MonthDayFromFields(_calendar_, _fields_, _options_).
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const expected = [
+ "get day",
+ "get day.valueOf",
+ "call day.valueOf",
+ "get month", // PlainMonthDay.month property does not exist, no valueOf
+ "get monthCode",
+ "get monthCode.toString",
+ "call monthCode.toString",
+ "get year", // undefined, no valueOf
+];
+
+const calendar = TemporalHelpers.calendarMergeFieldsGetters();
+const monthday = new Temporal.PlainMonthDay(3, 31, calendar);
+monthday.with({ day: 1 });
+
+assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copy-properties-not-undefined.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copy-properties-not-undefined.js
new file mode 100644
index 0000000000..8458c5bb3b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/copy-properties-not-undefined.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: PreparePartialTemporalFields copies only defined properties of source object
+info: |
+ 4. For each value _property_ of _fieldNames_, do
+ a. Let _value_ be ? Get(_fields_, _property_).
+ b. If _value_ is not *undefined*, then
+ ...
+ iii. Perform ! CreateDataPropertyOrThrow(_result_, _property_, _value_).
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const plainMonthDay = new Temporal.PlainMonthDay(10, 31);
+
+TemporalHelpers.assertPlainMonthDay(plainMonthDay.with({ day: 1, monthCode: undefined }),
+ "M10", 1,
+ "only the properties that are present and defined in the plain object are copied"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js
new file mode 100644
index 0000000000..566b013308
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js
@@ -0,0 +1,18 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError.
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['month'], ['year']]) {
+ const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields);
+ const md = new Temporal.PlainMonthDay(5, 1, calendar);
+
+ assert.throws(RangeError, () => md.with({day: 15}));
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/infinity-throws-rangeerror.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/infinity-throws-rangeerror.js
new file mode 100644
index 0000000000..bc7b3da926
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/infinity-throws-rangeerror.js
@@ -0,0 +1,25 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: Throws if any value in the property bag is Infinity or -Infinity
+esid: sec-temporal.plainmonthday.prototype.with
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainMonthDay(5, 2);
+
+[Infinity, -Infinity].forEach((inf) => {
+ ["constrain", "reject"].forEach((overflow) => {
+ assert.throws(RangeError, () => instance.with({ day: inf }, { overflow }), `day property cannot be ${inf} (overflow ${overflow}`);
+
+ const calls = [];
+ const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "day");
+ assert.throws(RangeError, () => instance.with({ day: obj }, { overflow }));
+ assert.compareArray(calls, ["get day.valueOf", "call day.valueOf"], "it fails after fetching the primitive value");
+ });
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/length.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/length.js
new file mode 100644
index 0000000000..dd129874fa
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/length.js
@@ -0,0 +1,28 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.plainmonthday.prototype.with
+description: Temporal.PlainMonthDay.prototype.with.length is 1
+info: |
+ Every built-in function object, including constructors, has a "length" property whose value is
+ an integer. Unless otherwise specified, this value is equal to the largest number of named
+ arguments shown in the subclause headings for the function description. Optional parameters
+ (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form
+ «...name») are not included in the default argument count.
+
+ Unless otherwise specified, the "length" property of a built-in function object has the
+ attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+verifyProperty(Temporal.PlainMonthDay.prototype.with, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/name.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/name.js
new file mode 100644
index 0000000000..c1a4873a71
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/name.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Temporal.PlainMonthDay.prototype.with.name is "with".
+info: |
+ Every built-in function object, including constructors, that is not identified as an anonymous
+ function has a "name" property whose value is a String. Unless otherwise specified, this value
+ is the name that is given to the function in this specification.
+
+ Unless otherwise specified, the "name" property of a built-in function object, if it exists,
+ has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+verifyProperty(Temporal.PlainMonthDay.prototype.with, "name", {
+ value: "with",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/not-a-constructor.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/not-a-constructor.js
new file mode 100644
index 0000000000..d47adfe1c3
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/not-a-constructor.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: >
+ Temporal.PlainMonthDay.prototype.with does not implement [[Construct]], is not new-able
+info: |
+ Built-in function objects that are not identified as constructors do not implement the
+ [[Construct]] internal method unless otherwise specified in the description of a particular
+ function.
+includes: [isConstructor.js]
+features: [Reflect.construct, Temporal]
+---*/
+
+assert.throws(TypeError, () => {
+ new Temporal.PlainMonthDay.prototype.with();
+}, "Calling as constructor");
+
+assert.sameValue(isConstructor(Temporal.PlainMonthDay.prototype.with), false,
+ "isConstructor(Temporal.PlainMonthDay.prototype.with)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-invalid.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-invalid.js
new file mode 100644
index 0000000000..d51439c247
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-invalid.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: TypeError thrown when options argument is a primitive
+features: [BigInt, Symbol, Temporal]
+---*/
+
+const instance = new Temporal.PlainMonthDay(2, 2);
+[null, true, "hello", Symbol("foo"), 1, 1n].forEach((badOptions) =>
+ assert.throws(TypeError, () => instance.with({ day: 17 }, badOptions))
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js
new file mode 100644
index 0000000000..29c79e3104
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-object.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Empty or a function object may be used as options
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainMonthDay(5, 2);
+
+const result1 = instance.with({ day: 5 }, {});
+TemporalHelpers.assertPlainMonthDay(
+ result1, "M05", 5,
+ "options may be an empty plain object"
+);
+
+const result2 = instance.with({ day: 5 }, () => {});
+TemporalHelpers.assertPlainMonthDay(
+ result2, "M05", 5,
+ "options may be a function object"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-undefined.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-undefined.js
new file mode 100644
index 0000000000..24134ef2ba
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-undefined.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Verify that undefined options are handled correctly.
+features: [Temporal]
+---*/
+
+const monthday = new Temporal.PlainMonthDay(2, 2);
+const fields = { day: 100 };
+
+const explicit = monthday.with(fields, undefined);
+assert.sameValue(explicit.day, 29, "default overflow is constrain");
+
+const implicit = monthday.with(fields);
+assert.sameValue(implicit.day, 29, "default overflow is constrain");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js
new file mode 100644
index 0000000000..c4026fa84c
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js
@@ -0,0 +1,26 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: TypeError thrown when options argument is a primitive
+features: [BigInt, Symbol, Temporal]
+---*/
+
+const badOptions = [
+ null,
+ true,
+ "some string",
+ Symbol(),
+ 1,
+ 2n,
+];
+
+const instance = new Temporal.PlainMonthDay(5, 2);
+for (const value of badOptions) {
+ assert.throws(TypeError, () => instance.with({ day: 5 }, value),
+ `TypeError on wrong options type ${typeof value}`);
+};
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js
new file mode 100644
index 0000000000..2311bf7a6f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js
@@ -0,0 +1,76 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// 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.plainmonthday.prototype.with
+description: Properties on an object passed to with() are accessed in the correct order
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const expected = [
+ // RejectObjectWithCalendarOrTimeZone
+ "get fields.calendar",
+ "get fields.timeZone",
+ // CopyDataProperties
+ "ownKeys options",
+ "getOwnPropertyDescriptor options.overflow",
+ "get options.overflow",
+ "getOwnPropertyDescriptor options.extra",
+ "get options.extra",
+ // lookup
+ "get this.calendar.fields",
+ "get this.calendar.mergeFields",
+ "get this.calendar.monthDayFromFields",
+ // CalendarFields
+ "call this.calendar.fields",
+ // PrepareTemporalFields on receiver
+ "get this.calendar.day",
+ "call this.calendar.day",
+ "get this.calendar.monthCode",
+ "call this.calendar.monthCode",
+ // PrepareTemporalFields on argument
+ "get fields.day",
+ "get fields.day.valueOf",
+ "call fields.day.valueOf",
+ "get fields.month",
+ "get fields.month.valueOf",
+ "call fields.month.valueOf",
+ "get fields.monthCode",
+ "get fields.monthCode.toString",
+ "call fields.monthCode.toString",
+ "get fields.year",
+ "get fields.year.valueOf",
+ "call fields.year.valueOf",
+ // CalendarMergeFields
+ "call this.calendar.mergeFields",
+ // CalendarMonthDayFromFields
+ "call this.calendar.monthDayFromFields",
+ // inside Calendar.p.monthDayFromFields
+ "get options.overflow.toString",
+ "call options.overflow.toString",
+];
+const actual = [];
+
+const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar");
+const instance = new Temporal.PlainMonthDay(5, 2, calendar);
+// clear observable operations that occurred during the constructor call
+actual.splice(0);
+
+const fields = TemporalHelpers.propertyBagObserver(actual, {
+ year: 1.7,
+ month: 1.7,
+ monthCode: "M01",
+ day: 1.7,
+}, "fields");
+
+const options = TemporalHelpers.propertyBagObserver(actual, {
+ overflow: "constrain",
+ extra: "property",
+}, "options");
+
+instance.with(fields, options);
+assert.compareArray(actual, expected, "order of operations");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-invalid-string.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-invalid-string.js
new file mode 100644
index 0000000000..bc845f5bb7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-invalid-string.js
@@ -0,0 +1,31 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: RangeError thrown when overflow option not one of the allowed string values
+info: |
+ sec-getoption step 10:
+ 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception.
+ sec-temporal-totemporaloverflow step 1:
+ 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
+ sec-temporal-isomonthdayfromfields step 2:
+ 2. Let _overflow_ be ? ToTemporalOverflow(_options_).
+ sec-temporal.plainmonthday.prototype.with step 16:
+ 16. Return ? MonthDayFromFields(_calendar_, _fields_, _options_).
+features: [Temporal]
+---*/
+
+const monthday = new Temporal.PlainMonthDay(5, 2);
+
+const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"];
+for (const overflow of badOverflows) {
+ assert.throws(
+ RangeError,
+ () => monthday.with({ day: 8 }, { overflow }),
+ `invalid overflow ("${overflow}")`
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-undefined.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-undefined.js
new file mode 100644
index 0000000000..0f93fe809d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-undefined.js
@@ -0,0 +1,29 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Fallback value for overflow option
+info: |
+ sec-getoption step 3:
+ 3. If _value_ is *undefined*, return _fallback_.
+ sec-temporal-totemporaloverflow step 1:
+ 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
+ sec-temporal-isomonthdayfromfields step 2:
+ 2. Let _overflow_ be ? ToTemporalOverflow(_options_).
+ sec-temporal.plainmonthday.prototype.with step 16:
+ 16. Return ? MonthDayFromFields(_calendar_, _fields_, _options_).
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const monthday = new Temporal.PlainMonthDay(5, 2);
+const explicit = monthday.with({ day: 33 }, { overflow: undefined });
+TemporalHelpers.assertPlainMonthDay(explicit, "M05", 31, "default overflow is constrain");
+const implicit = monthday.with({ day: 33 }, {});
+TemporalHelpers.assertPlainMonthDay(implicit, "M05", 31, "default overflow is constrain");
+const lambda = monthday.with({ day: 33 }, () => {});
+TemporalHelpers.assertPlainMonthDay(lambda, "M05", 31, "default overflow is constrain");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-wrong-type.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-wrong-type.js
new file mode 100644
index 0000000000..f6d4a649e8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/overflow-wrong-type.js
@@ -0,0 +1,27 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Type conversions for overflow option
+info: |
+ sec-getoption step 9.a:
+ a. Set _value_ to ? ToString(_value_).
+ sec-temporal-totemporaloverflow step 1:
+ 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*).
+ sec-temporal-isomonthdayfromfields step 2:
+ 2. Let _overflow_ be ? ToTemporalOverflow(_options_).
+ sec-temporal.plainmonthday.prototype.with step 16:
+ 16. Return ? MonthDayFromFields(_calendar_, _fields_, _options_).
+includes: [compareArray.js, temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const monthday = new Temporal.PlainMonthDay(5, 2);
+TemporalHelpers.checkStringOptionWrongType("overflow", "constrain",
+ (overflow) => monthday.with({ day: 8 }, { overflow }),
+ (result, descr) => TemporalHelpers.assertPlainMonthDay(result, "M05", 8, descr),
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/prop-desc.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/prop-desc.js
new file mode 100644
index 0000000000..32126c982f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/prop-desc.js
@@ -0,0 +1,24 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: The "with" property of Temporal.PlainMonthDay.prototype
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+assert.sameValue(
+ typeof Temporal.PlainMonthDay.prototype.with,
+ "function",
+ "`typeof PlainMonthDay.prototype.with` is `function`"
+);
+
+verifyProperty(Temporal.PlainMonthDay.prototype, "with", {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js
new file mode 100644
index 0000000000..805706edb6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js
@@ -0,0 +1,16 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2023 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError.
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']);
+const md = new Temporal.PlainMonthDay(5, 1, calendar);
+
+assert.throws(RangeError, () => md.with({day: 15}));
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/shell.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/shell.js
@@ -0,0 +1,24 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+ Test if a given function is a constructor function.
+defines: [isConstructor]
+features: [Reflect.construct]
+---*/
+
+function isConstructor(f) {
+ if (typeof f !== "function") {
+ throw new Test262Error("isConstructor invoked with a non-function value");
+ }
+
+ try {
+ Reflect.construct(function(){}, [], f);
+ } catch (e) {
+ return false;
+ }
+ return true;
+}
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/subclassing-ignored.js b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/subclassing-ignored.js
new file mode 100644
index 0000000000..a232d529d0
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainMonthDay/prototype/with/subclassing-ignored.js
@@ -0,0 +1,20 @@
+// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-temporal.plainmonthday.prototype.with
+description: Objects of a subclass are never created as return values for with()
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+TemporalHelpers.checkSubclassingIgnored(
+ Temporal.PlainMonthDay,
+ [5, 2],
+ "with",
+ [{ day: 20 }],
+ (result) => TemporalHelpers.assertPlainMonthDay(result, "M05", 20),
+);
+
+reportCompare(0, 0);