Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.duration.compare
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance_1 = new Temporal.Duration(1);
const instance_2 = new Temporal.Duration(2);

const invalidStrings = [
["", "empty string"],
["calendar: '1997-12-04[u-ca=iso8601]'", "ISO string with calendar annotation"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => Temporal.Duration.compare(instance_1, instance_2, { relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.duration.compare
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance_1 = new Temporal.Duration(1);
const instance_2 = new Temporal.Duration(2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => Temporal.Duration.compare(instance_1, instance_2, { relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.Duration(1, 0, 0, 0, 24);

const invalidStrings = [
["", "empty string"],
["calendar: '1997-12-04[u-ca=iso8601]'", "ISO string with calendar annotation"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.round({ largestUnit: "months", relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.Duration(1, 0, 0, 0, 24);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => instance.round({ largestUnit: "months", relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.Duration(1, 0, 0, 0, 24);

const invalidStrings = [
["", "empty string"],
["calendar: '1997-12-04[u-ca=iso8601]'", "ISO string with calendar annotation"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.total({ unit: "months", relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.Duration(1, 0, 0, 0, 24);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => instance.total({ unit: "months", relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

/*---
esid: sec-temporal.plaindate.constructor
description: Various invalid ISO string values for calendar
description: Invalid ISO string as calendar should throw RangeError
features: [Temporal]
---*/

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=iso8601]", "ISO string with calendar annotation"],
["notacal", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ features: [Temporal]

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) 2025 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: Invalid calendar string should throw RangeError
features: [Temporal]
---*/

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)),
`${description} is not a valid calendar ID (first argument)`
);
assert.throws(
RangeError,
() => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg),
`${description} is not a valid calendar ID (second argument)`
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

/*---
esid: sec-temporal.plaindate.from
description: Various invalid ISO string values for calendar in a property bag
description: Invalid ISO string as calendar should throw RangeError
features: [Temporal]
---*/

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => Temporal.PlainDate.from(arg),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (C) 2025 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: Invalid calendar string should throw RangeError
features: [Temporal]
---*/

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => Temporal.PlainDate.from(arg),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.plaindate.prototype.add
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["calendar: '1997-12-04[u-ca=iso8601]'", "ISO string with calendar annotation"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration({ months: 1, days: 2}), { relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.plaindate.prototype.add
description: Invalid ISO string as calendar in relativeTo option should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => instance.add(new Temporal.Duration({ months: 1, days: 2}), { relativeTo: arg }),
`${description} is not a valid calendar ID`
);
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const arg = { year: 1970, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.equals(arg),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => instance.equals(arg),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const arg = { year: 1970, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.since(arg),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2025 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: Invalid ISO string as calendar should throw RangeError
features: [Temporal]
---*/

const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
];

for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => instance.since(arg),
`${description} is not a valid calendar ID`
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const instance = new Temporal.PlainDate(2000, 5, 2);

const invalidStrings = [
["", "empty string"],
["1997-12-04[u-ca=notacal]", "Unknown calendar"],
["calendar: 'notacal'", "Unknown calendar"],
];

for (const [calendar, description] of invalidStrings) {
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
const arg = { year: 1970, monthCode: "M11", day: 18, calendar };
assert.throws(
RangeError,
() => instance.until(arg),
Expand Down
Loading