diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js index acd15f04db..9b43411db3 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit === "day" +description: Temporal.Calendar.prototype.dateUntil with largestUnit: "day" info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -15,28 +15,45 @@ info: | 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). features: [Temporal] +includes: [temporalHelpers.js] ---*/ let cal = new Temporal.Calendar("iso8601"); ["day", "days"].forEach(function(largestUnit) { let opt = {largestUnit}; - assert.sameValue("PT0S", cal.dateUntil("2021-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P1D", cal.dateUntil("2021-07-16", "2021-07-17", opt).toJSON()); - assert.sameValue("P32D", cal.dateUntil("2021-07-16", "2021-08-17", opt).toJSON()); - assert.sameValue("P62D", cal.dateUntil("2021-07-16", "2021-09-16", opt).toJSON()); - assert.sameValue("P365D", - cal.dateUntil("2021-07-16", "2022-07-16", opt).toJSON()); - assert.sameValue("P3652D" - ,cal.dateUntil("2021-07-16", "2031-07-16", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-17", opt), + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-09-16", opt), + 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-16", opt), + 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-07-16", opt), + 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); - assert.sameValue("-P1D", - cal.dateUntil("2021-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P32D", - cal.dateUntil("2021-08-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P62D", - cal.dateUntil("2021-09-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P365D", - cal.dateUntil("2022-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P3652D", - cal.dateUntil("2031-07-16", "2021-07-16", opt).toJSON()); + + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-17", "2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-17", "2021-07-16", opt), + 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-09-16", "2021-07-16", opt), + 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-16", "2021-07-16", opt), + 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2031-07-16", "2021-07-16", opt), + 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); }); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js index 79571e26a3..fa055aa35c 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit === "month" +description: Temporal.Calendar.prototype.dateUntil with largestUnit: "month" info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -15,44 +15,80 @@ info: | 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). features: [Temporal] +includes: [temporalHelpers.js] ---*/ let cal = new Temporal.Calendar("iso8601"); ["month", "months"].forEach(function(largestUnit) { let opt = {largestUnit}; - assert.sameValue("PT0S", cal.dateUntil("2021-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P1D", cal.dateUntil("2021-07-16", "2021-07-17", opt).toJSON()); - assert.sameValue("P7D", cal.dateUntil("2021-07-16", "2021-07-23", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2021-07-16", "2021-08-16", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2020-12-16", "2021-01-16", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2021-01-05", "2021-02-05", opt).toJSON()); - assert.sameValue("P2M", cal.dateUntil("2021-01-07", "2021-03-07", opt).toJSON()); - assert.sameValue("P1M1D", cal.dateUntil("2021-07-16", "2021-08-17", opt).toJSON()); - assert.sameValue("P28D", cal.dateUntil("2021-07-16", "2021-08-13", opt).toJSON()); - assert.sameValue("P2M", cal.dateUntil("2021-07-16", "2021-09-16", opt).toJSON()); - assert.sameValue("P12M", - cal.dateUntil("2021-07-16", "2022-07-16", opt).toJSON()); - assert.sameValue("P120M" - ,cal.dateUntil("2021-07-16", "2031-07-16", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-23", opt), + 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-12-16", "2021-01-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-05", "2021-02-05", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-07", "2021-03-07", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-17", opt), + 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-13", opt), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-09-16", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-16", opt), + 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, "12 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-07-16", opt), + 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, "120 months"); - assert.sameValue("-P1D", - cal.dateUntil("2021-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M1D", - cal.dateUntil("2021-08-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P28D", - cal.dateUntil("2021-08-13", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M", - cal.dateUntil("2021-08-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M3D", - cal.dateUntil("2021-08-16", "2021-07-13", opt).toJSON()); - assert.sameValue("-P2M", - cal.dateUntil("2021-09-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P2M5D", - cal.dateUntil("2021-09-21", "2021-07-16", opt).toJSON()); - assert.sameValue("-P12M", - cal.dateUntil("2022-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P12M1D", - cal.dateUntil("2022-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P120M", - cal.dateUntil("2031-07-16", "2021-07-16", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-17", "2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-23", "2021-07-16", opt), + 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-16", "2021-07-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-16", "2020-12-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-02-05", "2021-01-05", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-03-07", "2021-01-07", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-17", "2021-07-16", opt), + 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-13", "2021-07-16", opt), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-09-16", "2021-07-16", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-16", "2021-07-16", opt), + 0, -12, 0, 0, 0, 0, 0, 0, 0, 0, "negative 12 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("2031-07-16", "2021-07-16", opt), + 0, -120, 0, 0, 0, 0, 0, 0, 0, 0, "negative 120 months"); }); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js index 562633a32c..12031ec319 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit === "week" +description: Temporal.Calendar.prototype.dateUntil with largestUnit: "week" info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -15,32 +15,57 @@ info: | 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). features: [Temporal] +includes: [temporalHelpers.js] ---*/ let cal = new Temporal.Calendar("iso8601"); ["week", "weeks"].forEach(function(largestUnit) { let opt = {largestUnit}; - assert.sameValue("PT0S", cal.dateUntil("2021-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P1D", cal.dateUntil("2021-07-16", "2021-07-17", opt).toJSON()); - assert.sameValue("P1W", cal.dateUntil("2021-07-16", "2021-07-23", opt).toJSON()); - assert.sameValue("P4W4D", cal.dateUntil("2021-07-16", "2021-08-17", opt).toJSON()); - assert.sameValue("P4W", cal.dateUntil("2021-07-16", "2021-08-13", opt).toJSON()); - assert.sameValue("P8W6D", cal.dateUntil("2021-07-16", "2021-09-16", opt).toJSON()); - assert.sameValue("P52W1D", - cal.dateUntil("2021-07-16", "2022-07-16", opt).toJSON()); - assert.sameValue("P521W5D" - ,cal.dateUntil("2021-07-16", "2031-07-16", opt).toJSON()); - assert.sameValue("-P1D", - cal.dateUntil("2021-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P4W4D", - cal.dateUntil("2021-08-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P4W", - cal.dateUntil("2021-08-13", "2021-07-16", opt).toJSON()); - assert.sameValue("-P8W6D", - cal.dateUntil("2021-09-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P52W1D", - cal.dateUntil("2022-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P521W5D", - cal.dateUntil("2031-07-16", "2021-07-16", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-23", opt), + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-16", opt), + 0, 0, 4, 3, 0, 0, 0, 0, 0, 0, "4 weeks and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-13", opt), + 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, "4 weeks"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-09-16", opt), + 0, 0, 8, 6, 0, 0, 0, 0, 0, 0, "8 weeks and 6 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-16", opt), + 0, 0, 52, 1, 0, 0, 0, 0, 0, 0, "52 weeks and 1 day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-07-16", opt), + 0, 0, 521, 5, 0, 0, 0, 0, 0, 0, "521 weeks and 5 days"); + + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-17", "2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-23", "2021-07-16", opt), + 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-16", "2021-07-16", opt), + 0, 0, -4, -3, 0, 0, 0, 0, 0, 0, "negative 4 weeks and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-13", "2021-07-16", opt), + 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, "negative 4 weeks"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-09-16", "2021-07-16", opt), + 0, 0, -8, -6, 0, 0, 0, 0, 0, 0, "negative 8 weeks and 6 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-16", "2021-07-16", opt), + 0, 0, -52, -1, 0, 0, 0, 0, 0, 0, "negative 52 weeks and 1 day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2031-07-16", "2021-07-16", opt), + 0, 0, -521, -5, 0, 0, 0, 0, 0, 0, "negative 521 weeks and 5 days"); }); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js index 8bb906a98b..c1a01c5669 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit === "year" +description: Temporal.Calendar.prototype.dateUntil with largestUnit: "year" info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -15,110 +15,190 @@ info: | 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). features: [Temporal] +includes: [temporalHelpers.js] ---*/ let cal = new Temporal.Calendar("iso8601"); ["year", "years"].forEach(function(largestUnit) { let opt = {largestUnit}; - assert.sameValue("PT0S", cal.dateUntil("2021-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P1D", cal.dateUntil("2021-07-16", "2021-07-17", opt).toJSON()); - assert.sameValue("P7D", cal.dateUntil("2021-07-16", "2021-07-23", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2021-07-16", "2021-08-16", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2020-12-16", "2021-01-16", opt).toJSON()); - assert.sameValue("P1M", cal.dateUntil("2021-01-05", "2021-02-05", opt).toJSON()); - assert.sameValue("P2M", cal.dateUntil("2021-01-07", "2021-03-07", opt).toJSON()); - assert.sameValue("P1M1D", cal.dateUntil("2021-07-16", "2021-08-17", opt).toJSON()); - assert.sameValue("P28D", cal.dateUntil("2021-07-16", "2021-08-13", opt).toJSON()); - assert.sameValue("P2M", cal.dateUntil("2021-07-16", "2021-09-16", opt).toJSON()); - assert.sameValue("P1Y", - cal.dateUntil("2021-07-16", "2022-07-16", opt).toJSON()); - assert.sameValue("P1Y3D", - cal.dateUntil("2021-07-16", "2022-07-19", opt).toJSON()); - assert.sameValue("P1Y2M3D", - cal.dateUntil("2021-07-16", "2022-09-19", opt).toJSON()); - assert.sameValue("P10Y", - cal.dateUntil("2021-07-16", "2031-07-16", opt).toJSON()); - assert.sameValue("P10Y5M", - cal.dateUntil("2021-07-16", "2031-12-16", opt).toJSON()); - assert.sameValue("P23Y7M", - cal.dateUntil("1997-12-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P24Y", - cal.dateUntil("1997-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("P23Y11M29D", - cal.dateUntil("1997-07-16", "2021-07-15", opt).toJSON()); - assert.sameValue("P23Y11M30D", - cal.dateUntil("1997-06-16", "2021-06-15", opt).toJSON()); - assert.sameValue("P60Y1M", - cal.dateUntil("1960-02-16", "2020-03-16", opt).toJSON()); - assert.sameValue("P61Y27D", - cal.dateUntil("1960-02-16", "2021-03-15", opt).toJSON()); - assert.sameValue("P60Y28D", - cal.dateUntil("1960-02-16", "2020-03-15", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-23", opt), + 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-12-16", "2021-01-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-05", "2021-02-05", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-07", "2021-03-07", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-17", opt), + 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-13", opt), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-09-16", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-16", opt), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "1 year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-07-16", opt), + 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "10 years"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-19", opt), + 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, "1 year and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-09-19", opt), + 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, "1 year 2 months and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-12-16", opt), + 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, "10 years and 5 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("1997-12-16", "2021-07-16", opt), + 23, 7, 0, 0, 0, 0, 0, 0, 0, 0, "23 years and 7 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("1997-07-16", "2021-07-16", opt), + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "24 years"); + TemporalHelpers.assertDuration( + cal.dateUntil("1997-07-16", "2021-07-15", opt), + 23, 11, 0, 29, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 29 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("1997-06-16", "2021-06-15", opt), + 23, 11, 0, 30, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 30 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("1960-02-16", "2020-03-16", opt), + 60, 1, 0, 0, 0, 0, 0, 0, 0, 0, "60 years, 1 month"); + TemporalHelpers.assertDuration( + cal.dateUntil("1960-02-16", "2021-03-15", opt), + 61, 0, 0, 27, 0, 0, 0, 0, 0, 0, "61 years, 27 days in non leap year"); + TemporalHelpers.assertDuration( + cal.dateUntil("1960-02-16", "2020-03-15", opt), + 60, 0, 0, 28, 0, 0, 0, 0, 0, 0, "60 years, 28 days in leap year"); - assert.sameValue("P3M16D", - cal.dateUntil("2021-03-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P1Y3M16D", - cal.dateUntil("2020-03-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P61Y3M16D", - cal.dateUntil("1960-03-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P1Y6M16D", - cal.dateUntil("2019-12-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P6M16D", - cal.dateUntil("2020-12-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P23Y6M16D", - cal.dateUntil("1997-12-30", "2021-07-16", opt).toJSON()); - assert.sameValue("P2019Y6M21D", - cal.dateUntil("0001-12-25", "2021-07-16", opt).toJSON()); - assert.sameValue("P1Y2M5D", - cal.dateUntil("2019-12-30", "2021-03-05", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-03-30", "2021-07-16", opt), + 0, 3, 0, 16, 0, 0, 0, 0, 0, 0, "3 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-03-30", "2021-07-16", opt), + 1, 3, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 3 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("1960-03-30", "2021-07-16", opt), + 61, 3, 0, 16, 0, 0, 0, 0, 0, 0, "61 years, 3 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2019-12-30", "2021-07-16", opt), + 1, 6, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 6 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-12-30", "2021-07-16", opt), + 0, 6, 0, 16, 0, 0, 0, 0, 0, 0, "6 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("1997-12-30", "2021-07-16", opt), + 23, 6, 0, 16, 0, 0, 0, 0, 0, 0, "23 years, 6 months and 16 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("0001-12-25", "2021-07-16", opt), + 2019, 6, 0, 21, 0, 0, 0, 0, 0, 0, "2019 years, 6 months and 21 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2019-12-30", "2021-03-05", opt), + 1, 2, 0, 5, 0, 0, 0, 0, 0, 0, "1 year, 2 months and 5 days"); - assert.sameValue("-P1D", - cal.dateUntil("2021-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M1D", - cal.dateUntil("2021-08-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P28D", - cal.dateUntil("2021-08-13", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M", - cal.dateUntil("2021-08-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1M3D", - cal.dateUntil("2021-08-16", "2021-07-13", opt).toJSON()); - assert.sameValue("-P2M", - cal.dateUntil("2021-09-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P2M5D", - cal.dateUntil("2021-09-21", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1Y", - cal.dateUntil("2022-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1Y1D", - cal.dateUntil("2022-07-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P1Y3M1D", - cal.dateUntil("2022-10-17", "2021-07-16", opt).toJSON()); - assert.sameValue("-P10Y", - cal.dateUntil("2031-07-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P10Y11M", - cal.dateUntil("2032-07-16", "2021-08-16", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-17", "2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-23", "2021-07-16", opt), + 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-16", "2021-07-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-01-16", "2020-12-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-02-05", "2021-01-05", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-03-07", "2021-01-07", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-17", "2021-07-16", opt), + 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-13", "2021-07-16", opt), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-09-16", "2021-07-16", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-16", "2021-07-16", opt), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2031-07-16", "2021-07-16", opt), + -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-19", "2021-07-16", opt), + -1, 0, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2022-09-19", "2021-07-16", opt), + -1, -2, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year 2 months and 3 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2031-12-16", "2021-07-16", opt), + -10, -5, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years and 5 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "1997-12-16", opt), + -23, -7, 0, 0, 0, 0, 0, 0, 0, 0, "negative 23 years and 7 months"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "1997-07-16", opt), + -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 24 years"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-15", "1997-07-16", opt), + -23, -11, 0, -30, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 30 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-06-15", "1997-06-16", opt), + -23, -11, 0, -29, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 29 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-03-16", "1960-02-16", opt), + -60, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 60 years, 1 month"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-03-15", "1960-02-16", opt), + -61, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 61 years, 28 days in non leap year"); + TemporalHelpers.assertDuration( + cal.dateUntil("2020-03-15", "1960-02-16", opt), + -60, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 60 years, 28 days in leap year"); - assert.sameValue("-P10Y5M", - cal.dateUntil("2031-12-16", "2021-07-16", opt).toJSON()); - assert.sameValue("-P13Y7M", - cal.dateUntil("2011-07-16", "1997-12-16", opt).toJSON()); - assert.sameValue("-P24Y", - cal.dateUntil("2021-07-16", "1997-07-16", opt).toJSON()); - assert.sameValue("-P23Y11M30D", - cal.dateUntil("2021-07-15", "1997-07-16", opt).toJSON()); - assert.sameValue("-P23Y11M29D", - cal.dateUntil("2021-06-15", "1997-06-16", opt).toJSON()); - assert.sameValue("-P60Y1M", - cal.dateUntil("2020-03-16", "1960-02-16", opt).toJSON()); - assert.sameValue("-P61Y28D", - cal.dateUntil("2021-03-15", "1960-02-16", opt).toJSON()); - assert.sameValue("-P60Y28D", - cal.dateUntil("2020-03-15", "1960-02-16", opt).toJSON()); - - assert.sameValue("-P61Y3M17D", - cal.dateUntil("2021-07-16", "1960-03-30", opt).toJSON()); - - assert.sameValue("-P2019Y6M22D", - cal.dateUntil("2021-07-16", "0001-12-25", opt).toJSON()); - assert.sameValue("-P23Y6M17D", - cal.dateUntil("2021-07-16", "1997-12-30", opt).toJSON()); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-03-30", opt), + 0, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 3 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2020-03-30", opt), + -1, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 3 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "1960-03-30", opt), + -61, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 61 years, 3 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2019-12-30", opt), + -1, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 6 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2020-12-30", opt), + 0, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 6 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "1997-12-30", opt), + -23, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 23 years, 6 months and 17 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "0001-12-25", opt), + -2019, -6, 0, -22, 0, 0, 0, 0, 0, 0, "negative 2019 years, 6 months and 22 days"); + TemporalHelpers.assertDuration( + cal.dateUntil("2021-03-05", "2019-12-30", opt), + -1, -2, 0, -6, 0, 0, 0, 0, 0, 0, "negative 1 year, 2 months and 6 days"); }); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js index e0eea3ecf8..962400e354 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil w/o options +description: Temporal.Calendar.prototype.dateUntil with no options info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -15,18 +15,42 @@ info: | 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). features: [Temporal] +includes: [temporalHelpers.js] ---*/ let cal = new Temporal.Calendar("iso8601"); -assert.sameValue("PT0S", cal.dateUntil("2021-07-16", "2021-07-16").toJSON()); -assert.sameValue("P1D", cal.dateUntil("2021-07-16", "2021-07-17").toJSON()); -assert.sameValue("P32D", cal.dateUntil("2021-07-16", "2021-08-17").toJSON()); -assert.sameValue("P62D", cal.dateUntil("2021-07-16", "2021-09-16").toJSON()); -assert.sameValue("P365D", cal.dateUntil("2021-07-16", "2022-07-16").toJSON()); -assert.sameValue("P3652D", cal.dateUntil("2021-07-16", "2031-07-16").toJSON()); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-16"), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-07-17"), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-08-17"), + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2021-09-16"), + 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2022-07-16"), + 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-16", "2031-07-16"), + 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); -assert.sameValue("-P1D", cal.dateUntil("2021-07-17", "2021-07-16").toJSON()); -assert.sameValue("-P32D", cal.dateUntil("2021-08-17", "2021-07-16").toJSON()); -assert.sameValue("-P62D", cal.dateUntil("2021-09-16", "2021-07-16").toJSON()); -assert.sameValue("-P365D", cal.dateUntil("2022-07-16", "2021-07-16").toJSON()); -assert.sameValue("-P3652D", cal.dateUntil("2031-07-16", "2021-07-16").toJSON()); + +TemporalHelpers.assertDuration( + cal.dateUntil("2021-07-17", "2021-07-16"), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-08-17", "2021-07-16"), + 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2021-09-16", "2021-07-16"), + 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2022-07-16", "2021-07-16"), + 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); +TemporalHelpers.assertDuration( + cal.dateUntil("2031-07-16", "2021-07-16"), + 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js new file mode 100644 index 0000000000..6f5ddc7b99 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js @@ -0,0 +1,17 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: Temporal.Calendar.prototype.dateUntil throw RangeError on ToLargestTemporalUnit with invalide or disallowed unit +info: | + 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +["invalid", "hour", "minute", "second", "millisecond", "microsecond", + "nanosecond"].forEach(function(largestUnit) { + assert.throws(RangeError, () => cal.dateUntil("2021-07-16", "2022-03-04", {largestUnit}), + "Invalid or disallowed largestUnit cause ToLargestTemporalUnit to throw RangeError"); +}) diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js new file mode 100644 index 0000000000..dc0c3ed57c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: Temporal.Calendar.prototype.dateUntil throw RangeError on ToTemporalDate +info: | + 1. Let calendar be the this value. + 4. Set one to ? ToTemporalDate(one). + 5. Set two to ? ToTemporalDate(two). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.throws(RangeError, () => cal.dateUntil("2021-07-16", "invalide date"), + "Invalid date string will cause ToTemporalDate to throw RangeError"); +assert.throws(RangeError, () => cal.dateUntil("invalide date", "2021-07-16"), + "Invalid date string will cause ToTemporalDate to throw RangeError"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js new file mode 100644 index 0000000000..2aca08890b --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js @@ -0,0 +1,16 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: Temporal.Calendar.prototype.dateUntil throw TypeError on GetOptionsObject +info: | + 6. Set options to ? GetOptionsObject(options). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +["string", null, true, false, 123, 456n, Symbol(), Infinity, NaN].forEach(function (opt) { + assert.throws(TypeError, () => cal.dateUntil("2021-07-16", "2021-08-11", opt), + "Invalid options will cause GetOptionsObject to throw TypeError"); +}) diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-RequireInternalSlot.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-RequireInternalSlot.js new file mode 100644 index 0000000000..b4deb5b3de --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-RequireInternalSlot.js @@ -0,0 +1,16 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.dateuntil +description: Temporal.Calendar.prototype.dateUntil throw TypeError on RequireInternalSlot +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); +let badCal = { dateUntil: cal.dateUntil }; + +assert.throws(TypeError, () => badCal.dateUntil("2021-07-16", "2021-07-17"), + "call dateUntil from object without internal slot should throw TypeError");