summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar')
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js31
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js27
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/browser.js0
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js28
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin.js36
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js39
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js50
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js43
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js40
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js64
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js64
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/length.js28
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/missing-argument.js15
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/name.js26
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/not-a-constructor.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/prop-desc.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/shell.js24
-rw-r--r--js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js50
18 files changed, 613 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js
new file mode 100644
index 0000000000..daafac19f2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.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.plaindate.prototype.withcalendar
+description: Basic tests for withCalendar().
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const plainDate = Temporal.PlainDate.from("1976-11-18");
+const calendar = Temporal.Calendar.from("iso8601");
+
+const objectResult = plainDate.withCalendar(calendar);
+assert.notSameValue(objectResult, plainDate, "object: new object");
+TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object");
+assert.sameValue(objectResult.getCalendar(), calendar, "object: calendar");
+
+const stringResult = plainDate.withCalendar("iso8601");
+assert.notSameValue(stringResult, plainDate, "string: new object");
+TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string");
+assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string");
+
+const originalCalendar = plainDate.getCalendar();
+const sameResult = plainDate.withCalendar(originalCalendar);
+assert.notSameValue(sameResult, plainDate, "original: new object");
+TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original");
+assert.sameValue(sameResult.getCalendar(), originalCalendar, "original: calendar slot stores and object");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js
new file mode 100644
index 0000000000..b12a12f12d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: Throw a TypeError if the receiver is invalid
+features: [Symbol, Temporal]
+---*/
+
+const withCalendar = Temporal.PlainDate.prototype.withCalendar;
+
+assert.sameValue(typeof withCalendar, "function");
+
+const args = [new Temporal.Calendar("iso8601")];
+
+assert.throws(TypeError, () => withCalendar.apply(undefined, args), "undefined");
+assert.throws(TypeError, () => withCalendar.apply(null, args), "null");
+assert.throws(TypeError, () => withCalendar.apply(true, args), "true");
+assert.throws(TypeError, () => withCalendar.apply("", args), "empty string");
+assert.throws(TypeError, () => withCalendar.apply(Symbol(), args), "symbol");
+assert.throws(TypeError, () => withCalendar.apply(1, args), "1");
+assert.throws(TypeError, () => withCalendar.apply({}, args), "plain object");
+assert.throws(TypeError, () => withCalendar.apply(Temporal.PlainDate, args), "Temporal.PlainDate");
+assert.throws(TypeError, () => withCalendar.apply(Temporal.PlainDate.prototype, args), "Temporal.PlainDate.prototype");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/browser.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/browser.js
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js
new file mode 100644
index 0000000000..7869dea1f9
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js
@@ -0,0 +1,28 @@
+// |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.plaindate.prototype.withcalendar
+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 idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id");
+Object.defineProperty(Temporal.Calendar.prototype, "id", {
+ configurable: true,
+ enumerable: false,
+ get() {
+ TemporalHelpers.assertUnreachable("id should not be looked up");
+ },
+});
+
+const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601");
+instance.withCalendar("iso8601");
+
+Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin.js
new file mode 100644
index 0000000000..92c0aab861
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: >
+ Tests that Temporal.PlainDate.prototype.withCalendar
+ 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.PlainDate.prototype.withCalendar),
+ true, "Built-in objects must be extensible.");
+
+assert.sameValue(Object.prototype.toString.call(Temporal.PlainDate.prototype.withCalendar),
+ "[object Function]", "Object.prototype.toString");
+
+assert.sameValue(Object.getPrototypeOf(Temporal.PlainDate.prototype.withCalendar),
+ Function.prototype, "prototype");
+
+assert.sameValue(Temporal.PlainDate.prototype.withCalendar.hasOwnProperty("prototype"),
+ false, "prototype property");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js
new file mode 100644
index 0000000000..a367f57bf4
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js
@@ -0,0 +1,39 @@
+// |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.plaindate.prototype.withcalendar
+description: Calendar names are case-insensitive
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+
+const arg = "iSo8601";
+const result = instance.withCalendar(arg);
+assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js
new file mode 100644
index 0000000000..94eb9a3d7b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js
@@ -0,0 +1,50 @@
+// |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.plaindate.prototype.withcalendar
+description: A number is not allowed to be a calendar
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+
+const numbers = [
+ 1,
+ -19761118,
+ 19761118,
+ 1234567890,
+];
+
+for (const arg of numbers) {
+ assert.throws(
+ TypeError,
+ () => instance.withCalendar(arg),
+ "A number is not a valid ISO string for Calendar"
+ );
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js
new file mode 100644
index 0000000000..5c8fc1773b
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js
@@ -0,0 +1,43 @@
+// |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.plaindate.prototype.withcalendar
+description: Leap second is a valid ISO string for Calendar
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+
+const arg = "2016-12-31T23:59:60";
+const result = instance.withCalendar(arg);
+assert.sameValue(
+ result.calendarId,
+ "iso8601",
+ "leap second is a valid ISO string for Calendar"
+);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js
new file mode 100644
index 0000000000..8fb978666d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js
@@ -0,0 +1,40 @@
+// |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.plaindate.prototype.withcalendar
+description: A calendar ID is valid input for Calendar
+features: [Temporal]
+---*/
+
+const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+
+const arg = "iso8601";
+
+const result = instance.withCalendar(arg);
+assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js
new file mode 100644
index 0000000000..31039caed6
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js
@@ -0,0 +1,64 @@
+// |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.plaindate.prototype.withcalendar
+description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots
+info: |
+ sec-temporal-totemporalcalendar step 1.b:
+ b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
+ i. Return _temporalCalendarLike_.[[Calendar]].
+includes: [compareArray.js]
+features: [Temporal]
+---*/
+
+const plainDate = new Temporal.PlainDate(2000, 5, 2);
+const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
+const plainMonthDay = new Temporal.PlainMonthDay(5, 2);
+const plainYearMonth = new Temporal.PlainYearMonth(2000, 5);
+const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC");
+
+[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => {
+ const actual = [];
+ const expected = [];
+
+ const calendar = arg.getISOFields().calendar;
+
+ Object.defineProperty(arg, "calendar", {
+ get() {
+ actual.push("get calendar");
+ return calendar;
+ },
+ });
+
+ const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+ const result = instance.withCalendar(arg);
+ assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar");
+
+ assert.compareArray(actual, expected, "calendar getter not called");
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js
new file mode 100644
index 0000000000..c6184f42b7
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js
@@ -0,0 +1,64 @@
+// |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.plaindate.prototype.withcalendar
+description: >
+ Appropriate error thrown when argument cannot be converted to a valid string
+ or object for Calendar
+features: [BigInt, Symbol, Temporal]
+---*/
+
+const instance = new Temporal.PlainDate(1976, 11, 18, {
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ day() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ id: "replace-me",
+ inLeapYear() {},
+ mergeFields() {},
+ month() {},
+ monthCode() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ year() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+});
+
+const primitiveTests = [
+ [null, "null"],
+ [true, "boolean"],
+ ["", "empty string"],
+ [1, "number that doesn't convert to a valid ISO string"],
+ [1n, "bigint"],
+];
+
+for (const [arg, description] of primitiveTests) {
+ assert.throws(
+ typeof arg === 'string' ? RangeError : TypeError,
+ () => instance.withCalendar(arg),
+ `${description} does not convert to a valid ISO string`
+ );
+}
+
+const typeErrorTests = [
+ [Symbol(), "symbol"],
+ [{}, "plain object that doesn't implement the protocol"],
+ [new Temporal.TimeZone("UTC"), "time zone instance"],
+ [Temporal.Calendar, "Temporal.Calendar, object"],
+];
+
+for (const [arg, description] of typeErrorTests) {
+ assert.throws(TypeError, () => instance.withCalendar(arg), `${description} is not a valid object and does not convert to a string`);
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/length.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/length.js
new file mode 100644
index 0000000000..1c0d85af21
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: Temporal.PlainDate.prototype.withCalendar.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.PlainDate.prototype.withCalendar, "length", {
+ value: 1,
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/missing-argument.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/missing-argument.js
new file mode 100644
index 0000000000..c8d2409041
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/missing-argument.js
@@ -0,0 +1,15 @@
+// |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.plaindate.prototype.withcalendar
+description: TypeError thrown when calendar argument not given
+features: [Temporal]
+---*/
+
+const plainDate = Temporal.PlainDate.from("1976-11-18");
+assert.throws(TypeError, () => plainDate.withCalendar(), "missing argument");
+assert.throws(TypeError, () => plainDate.withCalendar(undefined), "undefined argument");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/name.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/name.js
new file mode 100644
index 0000000000..ff2da63f67
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: Temporal.PlainDate.prototype.withCalendar.name is "withCalendar".
+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.PlainDate.prototype.withCalendar, "name", {
+ value: "withCalendar",
+ writable: false,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/not-a-constructor.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/not-a-constructor.js
new file mode 100644
index 0000000000..222f96e84a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: >
+ Temporal.PlainDate.prototype.withCalendar 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.PlainDate.prototype.withCalendar();
+}, "Calling as constructor");
+
+assert.sameValue(isConstructor(Temporal.PlainDate.prototype.withCalendar), false,
+ "isConstructor(Temporal.PlainDate.prototype.withCalendar)");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/prop-desc.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/prop-desc.js
new file mode 100644
index 0000000000..3cb792447e
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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.plaindate.prototype.withcalendar
+description: The "withCalendar" property of Temporal.PlainDate.prototype
+includes: [propertyHelper.js]
+features: [Temporal]
+---*/
+
+assert.sameValue(
+ typeof Temporal.PlainDate.prototype.withCalendar,
+ "function",
+ "`typeof PlainDate.prototype.withCalendar` is `function`"
+);
+
+verifyProperty(Temporal.PlainDate.prototype, "withCalendar", {
+ writable: true,
+ enumerable: false,
+ configurable: true,
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/shell.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/shell.js
new file mode 100644
index 0000000000..eda1477282
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/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/PlainDate/prototype/withCalendar/subclassing-ignored.js b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js
new file mode 100644
index 0000000000..c188e3fe7a
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js
@@ -0,0 +1,50 @@
+// |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.plaindate.prototype.withcalendar
+description: Objects of a subclass are never created as return values.
+includes: [temporalHelpers.js]
+features: [Temporal]
+---*/
+
+const customCalendar = {
+ era() { return undefined; },
+ eraYear() { return undefined; },
+ year() { return 1900; },
+ month() { return 2; },
+ monthCode() { return "M02"; },
+ day() { return 5; },
+ id: "custom-calendar",
+ toString() { return "custom-calendar"; },
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ inLeapYear() {},
+ mergeFields() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+};
+
+TemporalHelpers.checkSubclassingIgnored(
+ Temporal.PlainDate,
+ [2000, 5, 2],
+ "withCalendar",
+ [customCalendar],
+ (result) => {
+ TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5);
+ assert.sameValue(result.getCalendar(), customCalendar, "calendar result");
+ },
+);
+
+reportCompare(0, 0);