From 84679fd7ed342e51e0b9de6573d94e099fa0bc6f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 15 Apr 2022 19:47:38 +0200 Subject: [PATCH] Temporal: Add a test for PlainDateTime#withPlainDate with intl calendars. (#3483) --- .../withPlainDate/argument-string-calendar.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js new file mode 100644 index 0000000000..2065751f71 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js @@ -0,0 +1,25 @@ +// 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.withplaindate +description: non-ISO calendars are handled correctly +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const isopdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 123, 456, 789); +const gregorypdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 123, 456, 789, "gregory"); + +const result1 = isopdt.withPlainDate("2020-11-13[u-ca=gregory]"); +TemporalHelpers.assertPlainDateTime(result1, 2020, 11, "M11", 13, 3, 24, 30, 123, 456, 789, + "result1", "ce", 2020); +assert.sameValue(result1.calendar.toString(), "gregory", "non-ISO calendar in argument overrides ISO calendar in receiver"); + +const result2 = gregorypdt.withPlainDate("2020-11-13[u-ca=iso8601]"); +TemporalHelpers.assertPlainDateTime(result2, 2020, 11, "M11", 13, 3, 24, 30, 123, 456, 789, + "result2", "ce", 2020); +assert.sameValue(result2.calendar.toString(), "gregory", "non-ISO calendar in receiver overrides ISO calendar in argument"); + +assert.throws(RangeError, () => gregorypdt.withPlainDate("2020-11-13[u-ca=japanese]"), + "throws if both `this` and `other` have a non-ISO calendar");