summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js')
-rw-r--r--js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js
new file mode 100644
index 0000000000..3def15ddb9
--- /dev/null
+++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js
@@ -0,0 +1,57 @@
+// |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.plaindatetime.prototype.withplaindate
+description: Original PDT calendar is preserved with ISO PlainDate
+features: [Temporal]
+includes: [temporalHelpers.js]
+---*/
+
+const cal = {
+ id: 'thisisnotiso',
+ era() { return "the era"; },
+ eraYear() { return 1909; },
+ toString() { return "this is a string"; },
+ year() { return 2008; },
+ month() { return 9; },
+ monthCode() { return "M09"; },
+ day() { return 6; },
+ dateAdd() {},
+ dateFromFields() {},
+ dateUntil() {},
+ dayOfWeek() {},
+ dayOfYear() {},
+ daysInMonth() {},
+ daysInWeek() {},
+ daysInYear() {},
+ fields() {},
+ inLeapYear() {},
+ mergeFields() {},
+ monthDayFromFields() {},
+ monthsInYear() {},
+ weekOfYear() {},
+ yearMonthFromFields() {},
+ yearOfWeek() {},
+};
+const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal);
+const pd = new Temporal.PlainDate(2010, 11, 12);
+assert.sameValue(pd.calendarId, "iso8601", "PlainDate with ISO calendar");
+const shifted = pdt.withPlainDate(pd);
+
+TemporalHelpers.assertPlainDateTime(
+ shifted,
+ 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0,
+ "calendar is unchanged if input has ISO calendar (1)",
+ "the era",
+ 1909
+);
+
+assert.sameValue(
+ shifted.getCalendar(),
+ cal,
+ "calendar is unchanged if input has ISO calendar (2)"
+);
+
+reportCompare(0, 0);