Test conversion of Number to Temporal objects

Adds tests for conversion of a Number whose corresponding toString() value
is a valid ISO string. For some Temporal types this is possible, with a
number like 20220418.

Especially for Temporal.Calendar, we have to take into account the case
where the number is provided as the value for the 'calendar' property in a
property bag, and the case of up to one level of nested property bag as
well.

Regularizes and expands existing tests for this case.
This commit is contained in:
Philip Chimento 2022-04-18 11:16:54 -07:00 committed by Philip Chimento
parent a38d3f3b67
commit afce1b3fde
114 changed files with 3957 additions and 32 deletions

View File

@ -0,0 +1,27 @@
// 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.calendar.from
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = Temporal.Calendar.from(arg);
assert.sameValue(result.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.Calendar.from(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,30 @@
// 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.calendar.prototype.dateadd
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.dateAdd(arg, new Temporal.Duration());
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.dateAdd(arg, new Temporal.Duration()),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,42 @@
// 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.calendar.prototype.dateadd
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.dateAdd(arg, new Temporal.Duration());
TemporalHelpers.assertPlainDate(result1, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.dateAdd(arg, new Temporal.Duration());
TemporalHelpers.assertPlainDate(result2, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.dateAdd(arg, new Temporal.Duration()),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.dateAdd(arg, new Temporal.Duration()),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,37 @@
// 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.calendar.prototype.dateuntil
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDate (first argument)");
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDate (second argument)");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 18)),
`Number ${arg} does not convert to a valid ISO string for PlainDate (first argument)`
);
assert.throws(
RangeError,
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 18), arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate (second argument)`
);
}

View File

@ -0,0 +1,56 @@
// 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.calendar.prototype.dateuntil
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (first argument)");
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (second argument)");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result3 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
TemporalHelpers.assertDuration(result3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
const result4 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
TemporalHelpers.assertDuration(result4, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property, second argument)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
`Number ${calendar} does not convert to a valid ISO string for calendar (first argument)`
);
assert.throws(
RangeError,
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, first argument)`
);
assert.throws(
RangeError,
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, second argument)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.day
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.day(arg);
assert.sameValue(result, 18, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.day(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.day
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.day(arg);
assert.sameValue(result1, 18, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.day(arg);
assert.sameValue(result2, 18, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.day(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.day(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.dayofweek
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.dayOfWeek(arg);
assert.sameValue(result, 4, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.dayOfWeek(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.dayofweek
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.dayOfWeek(arg);
assert.sameValue(result1, 4, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.dayOfWeek(arg);
assert.sameValue(result2, 4, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.dayOfWeek(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.dayOfWeek(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.dayofyear
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.dayOfYear(arg);
assert.sameValue(result, 323, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.dayOfYear(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.dayofyear
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.dayOfYear(arg);
assert.sameValue(result1, 323, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.dayOfYear(arg);
assert.sameValue(result2, 323, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.dayOfYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.dayOfYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.daysinmonth
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.daysInMonth(arg);
assert.sameValue(result, 30, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.daysInMonth(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.daysinmonth
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.daysInMonth(arg);
assert.sameValue(result1, 30, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.daysInMonth(arg);
assert.sameValue(result2, 30, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.daysInMonth(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.daysInMonth(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.daysinweek
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.daysInWeek(arg);
assert.sameValue(result, 7, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.daysInWeek(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.daysinweek
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.daysInWeek(arg);
assert.sameValue(result1, 7, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.daysInWeek(arg);
assert.sameValue(result2, 7, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.daysInWeek(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.daysInWeek(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.daysinyear
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.daysInYear(arg);
assert.sameValue(result, 366, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.daysInYear(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.daysinyear
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.daysInYear(arg);
assert.sameValue(result1, 366, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.daysInYear(arg);
assert.sameValue(result2, 366, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.daysInYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.daysInYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.inleapyear
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.inLeapYear(arg);
assert.sameValue(result, true, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.inLeapYear(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.inleapyear
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.inLeapYear(arg);
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.inLeapYear(arg);
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.inLeapYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.inLeapYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.month
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.month(arg);
assert.sameValue(result, 11, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.month(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.month
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.month(arg);
assert.sameValue(result1, 11, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.month(arg);
assert.sameValue(result2, 11, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.month(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.month(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.monthcode
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.monthCode(arg);
assert.sameValue(result, "M11", "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.monthCode(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.monthcode
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.monthCode(arg);
assert.sameValue(result1, "M11", "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.monthCode(arg);
assert.sameValue(result2, "M11", "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.monthCode(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.monthCode(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.monthsinyear
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.monthsInYear(arg);
assert.sameValue(result, 12, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.monthsInYear(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.monthsinyear
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.monthsInYear(arg);
assert.sameValue(result1, 12, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.monthsInYear(arg);
assert.sameValue(result2, 12, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.monthsInYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.monthsInYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.weekofyear
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.weekOfYear(arg);
assert.sameValue(result, 47, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.weekOfYear(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.weekofyear
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.weekOfYear(arg);
assert.sameValue(result1, 47, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.weekOfYear(arg);
assert.sameValue(result2, 47, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.weekOfYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.weekOfYear(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.calendar.prototype.year
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const arg = 19761118;
const result = instance.year(arg);
assert.sameValue(result, 1976, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.year(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.calendar.prototype.year
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Calendar("iso8601");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.year(arg);
assert.sameValue(result1, 1976, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.year(arg);
assert.sameValue(result2, 1976, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.year(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.year(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.duration.prototype.add
description: A number as relativeTo option is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 1);
const relativeTo = 20191101;
const result = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "20191101 is a valid ISO string for relativeTo");
const numbers = [
1,
-20191101,
1234567890,
];
for (const relativeTo of numbers) {
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
);
}

View File

@ -0,0 +1,42 @@
// 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.duration.prototype.add
description: A number as calendar in relativeTo property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 1);
const calendar = 19970327;
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
const result1 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
const result2 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
);
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.duration.prototype.round
description: A number as relativeTo option is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
const relativeTo = 20191101;
const result = instance.round({ largestUnit: "years", relativeTo });
TemporalHelpers.assertDuration(result, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "20191101 is a valid ISO string for relativeTo");
const numbers = [
1,
-20191101,
1234567890,
];
for (const relativeTo of numbers) {
assert.throws(
RangeError,
() => instance.round({ largestUnit: "years", relativeTo }),
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
);
}

View File

@ -0,0 +1,42 @@
// 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.duration.prototype.round
description: A number as calendar in relativeTo property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
const calendar = 19970327;
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
const result1 = instance.round({ largestUnit: "years", relativeTo });
TemporalHelpers.assertDuration(result1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
const result2 = instance.round({ largestUnit: "years", relativeTo });
TemporalHelpers.assertDuration(result2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.round({ largestUnit: "years", relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
);
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.round({ largestUnit: "years", relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.duration.prototype.subtract
description: A number as relativeTo option is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 1);
const relativeTo = 20191101;
const result = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "20191101 is a valid ISO string for relativeTo");
const numbers = [
1,
-20191101,
1234567890,
];
for (const relativeTo of numbers) {
assert.throws(
RangeError,
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
);
}

View File

@ -0,0 +1,42 @@
// 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.duration.prototype.subtract
description: A number as calendar in relativeTo property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 1);
const calendar = 19970327;
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
const result1 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
const result2 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
);
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.duration.prototype.total
description: A number as relativeTo option is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
const relativeTo = 20191101;
const result = instance.total({ unit: "days", relativeTo });
assert.sameValue(result, 367, "20191101 is a valid ISO string for relativeTo");
const numbers = [
1,
-20191101,
1234567890,
];
for (const relativeTo of numbers) {
assert.throws(
RangeError,
() => instance.total({ unit: "days", relativeTo }),
`Number ${relativeTo} does not convert to a valid ISO string for relativeTo`
);
}

View File

@ -0,0 +1,41 @@
// 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.duration.prototype.total
description: A number as calendar in relativeTo property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
const calendar = 19970327;
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
const result1 = instance.total({ unit: "days", relativeTo });
assert.sameValue(result1, 367, "19970327 is a valid ISO string for relativeTo.calendar");
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
const result2 = instance.total({ unit: "days", relativeTo });
assert.sameValue(result2, 367, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.total({ unit: "days", relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
);
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.total({ unit: "days", relativeTo }),
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.instant.prototype.tozoneddatetime
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
const arg = 19761118;
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,27 @@
// 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.now.plaindate
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = Temporal.Now.plainDate(arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.Now.plainDate(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,27 @@
// 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.now.plaindatetime
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = Temporal.Now.plainDateTime(arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.Now.plainDateTime(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,27 @@
// 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.now.zoneddatetime
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = Temporal.Now.zonedDateTime(arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.Now.zonedDateTime(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,27 @@
// 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
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = new Temporal.PlainDate(2000, 5, 2, arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => new Temporal.PlainDate(2000, 5, 2, arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,34 @@
// 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.compare
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const arg = 19761118;
const result1 = Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18));
assert.sameValue(result1, 0, "19761118 is a valid ISO string for PlainDate (first argument)");
const result2 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg);
assert.sameValue(result2, 0, "19761118 is a valid ISO string for PlainDate (second argument)");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)),
`Number ${arg} does not convert to a valid ISO string for PlainDate (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate (second argument)`
);
}

View File

@ -0,0 +1,53 @@
// 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.compare
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18));
assert.sameValue(result1, 0, "19970327 is a valid ISO string for calendar (first argument)");
const result2 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg);
assert.sameValue(result2, 0, "19970327 is a valid ISO string for calendar (first argument)");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result3 = Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18));
assert.sameValue(result3, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
const result4 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg);
assert.sameValue(result4, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)),
`Number ${calendar} does not convert to a valid ISO string for calendar (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, second argument)`
);
}

View File

@ -3,10 +3,26 @@
/*---
esid: sec-temporal.plaindate.from
description: various interesting string arguments.
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const result = Temporal.PlainDate.from(19761118);
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18);
const arg = 19761118;
const result = Temporal.PlainDate.from(arg);
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainDate.from(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,40 @@
// 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.from
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = Temporal.PlainDate.from(arg);
TemporalHelpers.assertPlainDate(result1, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = Temporal.PlainDate.from(arg);
TemporalHelpers.assertPlainDate(result2, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainDate.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainDate.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.equals
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const arg = 19761118;
const result = instance.equals(arg);
assert.sameValue(result, true, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.equals
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.equals(arg);
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.equals(arg);
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.since
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const arg = 19761118;
const result = instance.since(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,42 @@
// 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.since
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.since(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.since(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,31 @@
// 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.toplaindatetime
description: A number is converted to a string, then to Temporal.PlainTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(2000, 5, 2);
const arg = 123456.987654321;
const result = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.toPlainDateTime(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,30 @@
// 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.tozoneddatetime
description: A number is converted to a string, then to Temporal.PlainTime
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(2000, 5, 2);
const arg = 123456.987654321;
const result = instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" });
assert.sameValue(result.epochNanoseconds, 957270896_987_654_321n, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,30 @@
// 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.until
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const arg = 19761118;
const result = instance.until(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,42 @@
// 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.until
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.until(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.until(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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 converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
const arg = 19761118;
const result = instance.withCalendar(arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.withCalendar(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,27 @@
// 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
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,34 @@
// 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.compare
description: A number is converted to a string, then to Temporal.PlainDateTime
features: [Temporal]
---*/
let arg = 19761118;
const result1 = Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18));
assert.sameValue(result1, 0, "19761118 is a valid ISO string for PlainDateTime (first argument)");
const result2 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg);
assert.sameValue(result2, 0, "19761118 is a valid ISO string for PlainDateTime (second argument)");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime (second argument)`
);
}

View File

@ -0,0 +1,53 @@
// 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.compare
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18));
assert.sameValue(result1, 0, "19970327 is a valid ISO string for calendar (first argument)");
const result2 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg);
assert.sameValue(result2, 0, "19970327 is a valid ISO string for calendar (second argument)");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result3 = Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18));
assert.sameValue(result3, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
const result4 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg);
assert.sameValue(result4, 0, "19970327 is a valid ISO string for calendar (nested property, second argument)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)),
`Number ${calendar} does not convert to a valid ISO string for calendar (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, second argument)`
);
}

View File

@ -3,25 +3,26 @@
/*---
esid: sec-temporal.plaindatetime.from
description: A number is converted to a string, which may be a valid ISO string
features: [Temporal]
description: A number is converted to a string, then to Temporal.PlainDateTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.assertPlainDateTime(
Temporal.PlainDateTime.from(19761118),
1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0,
"Number may be an acceptable argument"
);
let arg = 19761118;
assert.throws(
RangeError,
() => Temporal.PlainDateTime.from(1),
"number, in decimal, has the wrong format (too few digits)"
);
const result = Temporal.PlainDateTime.from(arg);
TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDateTime");
assert.throws(
RangeError,
() => Temporal.PlainDateTime.from(1234567890),
"number, in decimal, has the wrong format (too many digits)"
);
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainDateTime.from(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,40 @@
// 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.from
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = Temporal.PlainDateTime.from(arg);
TemporalHelpers.assertPlainDateTime(result1, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = Temporal.PlainDateTime.from(arg);
TemporalHelpers.assertPlainDateTime(result2, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainDateTime.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainDateTime.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.equals
description: A number is converted to a string, then to Temporal.PlainDateTime
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
let arg = 19761118;
const result = instance.equals(arg);
assert.sameValue(result, true, "19761118 is a valid ISO string for PlainDateTime");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,41 @@
// 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.equals
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.equals(arg);
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.equals(arg);
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.since
description: A number is converted to a string, then to Temporal.PlainDateTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
let arg = 19761118;
const result = instance.since(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDateTime");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,42 @@
// 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.since
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.since(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.since(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.until
description: A number is converted to a string, then to Temporal.PlainDateTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
let arg = 19761118;
const result = instance.until(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19761118 is a valid ISO string for PlainDateTime");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,42 @@
// 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.until
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.until(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.until(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.withcalendar
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { id: "replace-me" });
const arg = 19761118;
const result = instance.withCalendar(arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.withCalendar(arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,30 @@
// 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: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
const arg = 19761118;
const result = instance.withPlainDate(arg);
TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.withPlainDate(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,42 @@
// 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: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.withPlainDate(arg);
TemporalHelpers.assertPlainDateTime(result1, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.withPlainDate(arg);
TemporalHelpers.assertPlainDateTime(result2, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.withPlainDate(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.withPlainDate(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,31 @@
// 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.withplaintime
description: A number is converted to a string, then to Temporal.PlainTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainDateTime(2000, 5, 2);
const arg = 123456.987654321;
const result = instance.withPlainTime(arg);
TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.withPlainTime(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,27 @@
// 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
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = new Temporal.PlainMonthDay(12, 15, arg, 1972);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => new Temporal.PlainMonthDay(12, 15, arg, 1972),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,28 @@
// 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.from
description: A number is converted to a string, then to Temporal.PlainMonthDay
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const arg = 1118;
const result = Temporal.PlainMonthDay.from(arg);
TemporalHelpers.assertPlainMonthDay(result, "M11", 18, "1118 is a valid ISO string for PlainMonthDay");
const numbers = [
1,
-1118,
12345,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainMonthDay.from(arg),
`Number ${arg} does not convert to a valid ISO string for PlainMonthDay`
);
}

View File

@ -0,0 +1,40 @@
// 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.from
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { monthCode: "M11", day: 18, calendar };
const result1 = Temporal.PlainMonthDay.from(arg);
TemporalHelpers.assertPlainMonthDay(result1, "M11", 18, "19970327 is a valid ISO string for calendar");
arg = { monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = Temporal.PlainMonthDay.from(arg);
TemporalHelpers.assertPlainMonthDay(result2, "M11", 18, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainMonthDay.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainMonthDay.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.equals
description: A number is converted to a string, then to Temporal.PlainMonthDay
features: [Temporal]
---*/
const instance = new Temporal.PlainMonthDay(11, 18);
const arg = 1118;
const result = instance.equals(arg);
assert.sameValue(result, true, "1118 is a valid ISO string for PlainMonthDay");
const numbers = [
1,
-1118,
12345,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${arg} does not convert to a valid ISO string for PlainMonthDay`
);
}

View File

@ -0,0 +1,41 @@
// 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.equals
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainMonthDay(11, 18);
const calendar = 19970327;
let arg = { monthCode: "M11", day: 18, calendar };
const result1 = instance.equals(arg);
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
arg = { monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.equals(arg);
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,35 @@
// 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.plaintime.compare
description: A number is converted to a string, then to Temporal.PlainTime
features: [Temporal]
---*/
const arg = 123456.987654321;
const result1 = Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321));
assert.sameValue(result1, 0, "123456.987654321 is a valid ISO string for PlainTime (first argument)");
const result2 = Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg);
assert.sameValue(result2, 0, "123456.987654321 is a valid ISO string for PlainTime (second argument)");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)),
`Number ${arg} does not convert to a valid ISO string for PlainTime (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime (second argument)`
);
}

View File

@ -3,10 +3,27 @@
/*---
esid: sec-temporal.plaintime.from
description: Number argument is converted to string
includes: [compareArray.js, temporalHelpers.js]
description: A number is converted to a string, then to Temporal.PlainTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const result = Temporal.PlainTime.from(1523);
TemporalHelpers.assertPlainTime(result, 15, 23, 0, 0, 0, 0);
const arg = 123456.987654321;
const result = Temporal.PlainTime.from(arg);
TemporalHelpers.assertPlainTime(result, 12, 34, 56, 987, 654, 321, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainTime.from(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,30 @@
// 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.plaintime.prototype.equals
description: A number is converted to a string, then to Temporal.PlainTime
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const arg = 123456.987654321;
const result = instance.equals(arg);
assert.sameValue(result, true, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,31 @@
// 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.plaintime.prototype.since
description: A number is converted to a string, then to Temporal.PlainTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const arg = 123456.987654321;
const result = instance.since(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,30 @@
// 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.plaintime.prototype.toplaindatetime
description: A number is converted to a string, then to Temporal.PlainDate
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const arg = 19761118;
const result = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.toPlainDateTime(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,42 @@
// 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.plaintime.prototype.toplaindatetime
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(result1, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.toPlainDateTime(arg);
TemporalHelpers.assertPlainDateTime(result2, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.toPlainDateTime(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.toPlainDateTime(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.plaintime.prototype.tozoneddatetime
description: A number is converted to a string, then to Temporal.PlainDate
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const arg = 19761118;
const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" });
assert.sameValue(result.epochNanoseconds, 217_168_496_987_654_321n, "19761118 is a valid ISO string for PlainDate");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }),
`Number ${arg} does not convert to a valid ISO string for PlainDate`
);
}

View File

@ -0,0 +1,41 @@
// 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.plaintime.prototype.tozoneddatetime
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" });
assert.sameValue(result1.epochNanoseconds, 217_168_496_987_654_321n, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" });
assert.sameValue(result2.epochNanoseconds, 217_168_496_987_654_321n, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,31 @@
// 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.plaintime.prototype.until
description: A number is converted to a string, then to Temporal.PlainTime
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
const arg = 123456.987654321;
const result = instance.until(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "123456.987654321 is a valid ISO string for PlainTime");
const numbers = [
1,
-123456.987654321,
1234567,
123456.9876543219,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${arg} does not convert to a valid ISO string for PlainTime`
);
}

View File

@ -0,0 +1,27 @@
// 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.plainyearmonth
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const arg = 19761118;
const result = new Temporal.PlainYearMonth(2000, 5, arg, 1);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => new Temporal.PlainYearMonth(2000, 5, arg, 1),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,34 @@
// 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.plainyearmonth.compare
description: A number is converted to a string, then to Temporal.PlainYearMonth
features: [Temporal]
---*/
const arg = 201906;
const result1 = Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6));
assert.sameValue(result1, 0, "201906 is a valid ISO string for PlainYearMonth (first argument)");
const result2 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg);
assert.sameValue(result2, 0, "201906 is a valid ISO string for PlainYearMonth (second argument)");
const numbers = [
1,
-201906,
1234567,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth (first argument)`
);
}

View File

@ -0,0 +1,53 @@
// 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.plainyearmonth.compare
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 2019, monthCode: "M06", calendar };
const result1 = Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6));
assert.sameValue(result1, 0, "19970327 is a valid ISO string for calendar (first argument)");
const result2 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg);
assert.sameValue(result2, 0, "19970327 is a valid ISO string for calendar (second argument)");
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
const result3 = Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6));
assert.sameValue(result3, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
const result4 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg);
assert.sameValue(result4, 0, "19970327 is a valid ISO string for calendar (nested property, second argument)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 2019, monthCode: "M06", calendar };
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)),
`Number ${calendar} does not convert to a valid ISO string for calendar (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
);
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, second argument)`
);
}

View File

@ -3,15 +3,26 @@
/*---
esid: sec-temporal.plainyearmonth.from
description: A number argument is stringified
description: A number is converted to a string, then to Temporal.PlainYearMonth
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const plainYearMonth = Temporal.PlainYearMonth.from(201906);
TemporalHelpers.assertPlainYearMonth(plainYearMonth, 2019, 6, "M06");
const fields = plainYearMonth.getISOFields();
assert.sameValue(fields.calendar.id, "iso8601");
assert.sameValue(fields.isoDay, 1, "isoDay");
assert.sameValue(fields.isoMonth, 6, "isoMonth");
assert.sameValue(fields.isoYear, 2019, "isoYear");
const arg = 201906;
const result = Temporal.PlainYearMonth.from(arg);
TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", "201906 is a valid ISO string for PlainYearMonth");
const numbers = [
1,
-201906,
1234567,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.from(arg),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth`
);
}

View File

@ -0,0 +1,40 @@
// 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.plainyearmonth.from
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = 19970327;
let arg = { year: 2019, monthCode: "M06", calendar };
const result1 = Temporal.PlainYearMonth.from(arg);
TemporalHelpers.assertPlainYearMonth(result1, 2019, 6, "M06", "19970327 is a valid ISO string for calendar");
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
const result2 = Temporal.PlainYearMonth.from(arg);
TemporalHelpers.assertPlainYearMonth(result2, 2019, 6, "M06", "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 2019, monthCode: "M06", calendar };
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
assert.throws(
RangeError,
() => Temporal.PlainYearMonth.from(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.plainyearmonth.prototype.equals
description: A number is converted to a string, then to Temporal.PlainYearMonth
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const arg = 201906;
const result = instance.equals(arg);
assert.sameValue(result, true, "201906 is a valid ISO string for PlainYearMonth");
const numbers = [
1,
-201906,
1234567,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth`
);
}

View File

@ -0,0 +1,41 @@
// 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.plainyearmonth.prototype.equals
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const calendar = 19970327;
let arg = { year: 2019, monthCode: "M06", calendar };
const result1 = instance.equals(arg);
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
const result2 = instance.equals(arg);
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 2019, monthCode: "M06", calendar };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
assert.throws(
RangeError,
() => instance.equals(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.plainyearmonth.prototype.since
description: A number is converted to a string, then to Temporal.PlainYearMonth
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const arg = 201906;
const result = instance.since(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "201906 is a valid ISO string for PlainYearMonth");
const numbers = [
1,
-201906,
1234567,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth`
);
}

View File

@ -0,0 +1,42 @@
// 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.plainyearmonth.prototype.since
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const calendar = 19970327;
let arg = { year: 2019, monthCode: "M06", calendar };
const result1 = instance.since(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
const result2 = instance.since(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 2019, monthCode: "M06", calendar };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
assert.throws(
RangeError,
() => instance.since(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,30 @@
// 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.plainyearmonth.prototype.until
description: A number is converted to a string, then to Temporal.PlainYearMonth
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const arg = 201906;
const result = instance.until(arg);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "201906 is a valid ISO string for PlainYearMonth");
const numbers = [
1,
-201906,
1234567,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${arg} does not convert to a valid ISO string for PlainYearMonth`
);
}

View File

@ -0,0 +1,42 @@
// 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.plainyearmonth.prototype.until
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.PlainYearMonth(2019, 6);
const calendar = 19970327;
let arg = { year: 2019, monthCode: "M06", calendar };
const result1 = instance.until(arg);
TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar");
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
const result2 = instance.until(arg);
TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 2019, monthCode: "M06", calendar };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 2019, monthCode: "M06", calendar: { calendar } };
assert.throws(
RangeError,
() => instance.until(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.timezone.prototype.getinstantfor
description: A number is converted to a string, then to Temporal.PlainDateTime
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
let arg = 19761118;
const result = instance.getInstantFor(arg);
assert.sameValue(result.epochNanoseconds, 217_123_200_000_000_000n, "19761118 is a valid ISO string for PlainDateTime");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.getInstantFor(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,41 @@
// 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.timezone.prototype.getinstantfor
description: A number as calendar in a property bag is converted to a string, then to a calendar
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.getInstantFor(arg);
assert.sameValue(result1.epochNanoseconds, 217_123_200_000_000_000n, "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.getInstantFor(arg);
assert.sameValue(result2.epochNanoseconds, 217_123_200_000_000_000n, "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.getInstantFor(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.getInstantFor(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

View File

@ -0,0 +1,29 @@
// 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.timezone.prototype.getplaindatetimefor
description: A number is converted to a string, then to Temporal.Calendar
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const arg = 19761118;
const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg);
assert.sameValue(result.calendar.id, "iso8601", "19761118 is a valid ISO string for Calendar");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg),
`Number ${arg} does not convert to a valid ISO string for Calendar`
);
}

View File

@ -0,0 +1,30 @@
// 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.timezone.prototype.getpossibleinstantsfor
description: A number is converted to a string, then to Temporal.PlainDateTime
includes: [compareArray.js]
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
let arg = 19761118;
const result = instance.getPossibleInstantsFor(arg);
assert.compareArray(result.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], "19761118 is a valid ISO string for PlainDateTime");
const numbers = [
1,
-19761118,
1234567890,
];
for (const arg of numbers) {
assert.throws(
RangeError,
() => instance.getPossibleInstantsFor(arg),
`Number ${arg} does not convert to a valid ISO string for PlainDateTime`
);
}

View File

@ -0,0 +1,42 @@
// 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.timezone.prototype.getpossibleinstantsfor
description: A number as calendar in a property bag is converted to a string, then to a calendar
includes: [compareArray.js]
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const calendar = 19970327;
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const result1 = instance.getPossibleInstantsFor(arg);
assert.compareArray(result1.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], "19970327 is a valid ISO string for calendar");
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
const result2 = instance.getPossibleInstantsFor(arg);
assert.compareArray(result2.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], "19970327 is a valid ISO string for calendar (nested property)");
const numbers = [
1,
-19970327,
1234567890,
];
for (const calendar of numbers) {
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.getPossibleInstantsFor(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar`
);
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
assert.throws(
RangeError,
() => instance.getPossibleInstantsFor(arg),
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
);
}

Some files were not shown because too many files have changed in this diff Show More