mirror of https://github.com/tc39/test262.git
Test wrong types in conversions to Temporal types
These tests cover, for every API entry point where a Temporal object is expected, what happens when a value of a different type is passed in that can't be converted. Most entry points can convert a string to the expected Temporal type, and will do ToString on any non-Object argument, and throw RangeError if the result isn't a string that's convertible to that Temporal type. ToString will throw TypeError on a Symbol. Most entry points also take a property bag, and will throw TypeError if the property bag doesn't have the required properties. We also have to test for TimeZone and Calendar what happens if the wrong type is provided as the value of a 'timeZone' or 'calendar' property in another property bag, up to one level of nested properties.
This commit is contained in:
parent
afce1b3fde
commit
78c6ec7f1c
|
@ -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.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Calendar.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Calendar.from(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
52
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
52
test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (nested property, first argument)`);
|
||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (nested property, first argument)`);
|
||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `nested undefined calendar property is always a RangeError (first argument)`);
|
||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `nested undefined calendar property is always a RangeError (second argument)`);
|
|
@ -0,0 +1,39 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.day(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.daysInYear(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.month(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.monthCode(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.year(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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.compare
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
|
49
test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
49
test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo.calendar cannot be converted to a
|
||||
calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,39 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo cannot be converted to a valid
|
||||
relativeTo string or property bag
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration(1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
|
49
test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
49
test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo.calendar cannot be converted to a
|
||||
calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,39 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo cannot be converted to a valid
|
||||
relativeTo string or property bag
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration(1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo.calendar cannot be converted to a
|
||||
calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `nested undefined calendar property is always a RangeError`);
|
39
test/built-ins/Temporal/Duration/prototype/subtract/relativeto-wrong-type.js
vendored
Normal file
39
test/built-ins/Temporal/Duration/prototype/subtract/relativeto-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo cannot be converted to a valid
|
||||
relativeTo string or property bag
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration(1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(1), { relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
|
49
test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
49
test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo.calendar cannot be converted to a
|
||||
calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,39 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when relativeTo cannot be converted to a valid
|
||||
relativeTo string or property bag
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
[Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
|
||||
[Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [relativeTo, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Duration(1);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone: { timeZone } } }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,39 @@
|
|||
// 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.compare
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
for Instant
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const other = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.Instant, "Temporal.Instant, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Instant.compare(arg, other), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.Instant.compare(other, arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Instant.compare(arg, other), `${description} does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.Instant.compare(other, arg), `${description} does not convert to a string (second argument)`);
|
||||
}
|
|
@ -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.instant.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
for Instant
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.Instant, "Temporal.Instant, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Instant.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Instant.from(arg), `${description} does not convert to a string`);
|
||||
}
|
|
@ -1,20 +1,37 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// 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.equals
|
||||
description: Appropriate error thrown when argument cannot be converted to a valid string
|
||||
features: [Symbol, Temporal]
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
for Instant
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.Instant.fromEpochSeconds(0);
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
assert.throws(RangeError, () => instance.equals(undefined), "undefined");
|
||||
assert.throws(RangeError, () => instance.equals(null), "null");
|
||||
assert.throws(RangeError, () => instance.equals(true), "true");
|
||||
assert.throws(RangeError, () => instance.equals(""), "empty string");
|
||||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol");
|
||||
assert.throws(RangeError, () => instance.equals(1), "1");
|
||||
assert.throws(RangeError, () => instance.equals({}), "plain object");
|
||||
assert.throws(RangeError, () => instance.equals(Temporal.Instant), "Temporal.Instant");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.Instant.prototype), "Temporal.Instant.prototype");
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.Instant, "Temporal.Instant, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} does not convert to a string`);
|
||||
}
|
||||
|
|
|
@ -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.instant.prototype.since
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
for Instant
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.Instant, "Temporal.Instant, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// 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.tostring
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toString({ timeZone }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.toString({ timeZone: { timeZone } }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toString({ timeZone }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.toString({ timeZone: { timeZone } }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.toString({ timeZone: { timeZone } }), `undefined is always a RangeError as nested property`);
|
32
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js
vendored
Normal file
32
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
38
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
38
test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: { timeZone }, calendar: "iso8601" }), `undefined is always a RangeError as nested property`);
|
38
test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js
vendored
Normal file
38
test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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.tozoneddatetimeiso
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTimeISO(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.toZonedDateTimeISO({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTimeISO(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.toZonedDateTimeISO({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.toZonedDateTimeISO({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -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.instant.prototype.until
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
for Instant
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.Instant, "Temporal.Instant, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} does not convert to a string`);
|
||||
}
|
|
@ -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.now.plaindate
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDate(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", { timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDate("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDate("iso8601", { timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", { timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindateiso
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateISO({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateISO(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateISO({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateISO({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -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.now.plaindatetime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateTime(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", { timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateTime("iso8601", { timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", { timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindatetimeiso
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateTimeISO(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.plainDateTimeISO({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.plainDateTimeISO({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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.plaintimeiso
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.plainTimeISO({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.plainTimeISO(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.plainTimeISO({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.plainTimeISO({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -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.now.zoneddatetime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.zonedDateTime(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", { timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.zonedDateTime("iso8601", { timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", { timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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.zoneddatetimeiso
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTimeISO(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTimeISO({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.Now.zonedDateTimeISO(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => Temporal.Now.zonedDateTimeISO({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => Temporal.Now.zonedDateTimeISO({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -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
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => new Temporal.PlainDate(2000, 5, 2, arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => new Temporal.PlainDate(2000, 5, 2, arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} does not convert to a valid ISO string (nested property, first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (nested property, first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `nested undefined calendar property is always a RangeError (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `nested undefined calendar property is always a RangeError (second argument)`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.from(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.from(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.from(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -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.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainDate.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
47
test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -1,17 +1,36 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// 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: Appropriate error thrown when argument cannot be converted to a valid string
|
||||
features: [Symbol, Temporal]
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2 });
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
assert.throws(RangeError, () => instance.equals(undefined), "undefined");
|
||||
assert.throws(RangeError, () => instance.equals(null), "null");
|
||||
assert.throws(RangeError, () => instance.equals(true), "true");
|
||||
assert.throws(RangeError, () => instance.equals(""), "empty string");
|
||||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol");
|
||||
assert.throws(RangeError, () => instance.equals(1), "1");
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
||||
|
|
47
test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.since(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
35
test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-wrong-type.js
vendored
Normal file
35
test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-wrong-type.js
vendored
Normal 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.plaindate.prototype.toplaindatetime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toPlainDateTime(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toPlainDateTime(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
35
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-wrong-type.js
vendored
Normal file
35
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/argument-wrong-type.js
vendored
Normal 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.plaindate.prototype.tozoneddatetime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ plainTime: arg, timeZone: "UTC" }), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
38
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
38
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone }), `undefined is always a RangeError as nested property`);
|
47
test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
47
test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.until(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
32
test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js
vendored
Normal file
32
test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDate(1976, 11, 18, { id: "replace-me" });
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.withCalendar(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.withCalendar(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -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
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} does not convert to a valid ISO string (nested property, first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (nested property, first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (nested property, second argument)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `nested undefined calendar property is always a RangeError (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `nested undefined calendar property is always a RangeError (second argument)`);
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDateTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDateTime, "Temporal.PlainDateTime, object"],
|
||||
[Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.from(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -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.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDateTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDateTime, "Temporal.PlainDateTime, object"],
|
||||
[Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -1,20 +1,36 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// 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: Appropriate error thrown when argument cannot be converted to a valid string
|
||||
features: [Symbol, Temporal]
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDateTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 });
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
assert.throws(RangeError, () => instance.equals(undefined), "undefined");
|
||||
assert.throws(RangeError, () => instance.equals(null), "null");
|
||||
assert.throws(RangeError, () => instance.equals(true), "true");
|
||||
assert.throws(RangeError, () => instance.equals(""), "empty string");
|
||||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol");
|
||||
assert.throws(RangeError, () => instance.equals(1), "1");
|
||||
assert.throws(TypeError, () => instance.equals({}), "plain object");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainDateTime), "Temporal.PlainDateTime");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype");
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDateTime, "Temporal.PlainDateTime, object"],
|
||||
[Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.since(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/PlainDateTime/prototype/since/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/since/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDateTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.since(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDateTime, "Temporal.PlainDateTime, object"],
|
||||
[Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.since(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
38
test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
38
test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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.tozoneddatetime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for TimeZone
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), `${description} does not convert to a valid ISO string`);
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone }), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime(timeZone), `${description} is not a valid object and does not convert to a string`);
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone }), `${description} is not a valid object and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const timeZone = undefined;
|
||||
assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone }), `undefined is always a RangeError as nested property`);
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.until(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/PlainDateTime/prototype/until/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/until/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDateTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.until(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDateTime, "Temporal.PlainDateTime, object"],
|
||||
[Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.until(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
32
test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js
vendored
Normal file
32
test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { id: "replace-me" });
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.withCalendar(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.withCalendar(arg), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.withPlainDate(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.withPlainDate(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.withPlainDate(arg), `nested undefined calendar property is always a RangeError`);
|
36
test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainDate
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.withPlainDate(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainDate, "Temporal.PlainDate, object"],
|
||||
[Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
35
test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-wrong-type.js
vendored
Normal file
35
test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-wrong-type.js
vendored
Normal 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.plaindatetime.prototype.withplaintime
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.withPlainTime(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.withPlainTime(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -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.plainmonthday
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or object for Calendar
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => new Temporal.PlainMonthDay(12, 15, arg, 1972), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => new Temporal.PlainMonthDay(12, 15, arg, 1972), `${description} is not a valid object and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => Temporal.PlainMonthDay.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => Temporal.PlainMonthDay.from(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -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.plainmonthday.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainMonthDay
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainMonthDay, "Temporal.PlainMonthDay, object"],
|
||||
[Temporal.PlainMonthDay.prototype, "Temporal.PlainMonthDay.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainMonthDay.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when a calendar property from a property bag cannot
|
||||
be converted to a calendar object or string
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const timeZone = new Temporal.TimeZone("UTC");
|
||||
const instance = new Temporal.PlainMonthDay(5, 2);
|
||||
|
||||
const rangeErrorTests = [
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [calendar, description] of rangeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"], // TypeError due to missing dateFromFields()
|
||||
[Temporal.Calendar, "Temporal.Calendar, object"], // ditto
|
||||
[Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields()
|
||||
];
|
||||
|
||||
for (const [calendar, description] of typeErrorTests) {
|
||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
|
||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
||||
}
|
||||
|
||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
||||
assert.throws(RangeError, () => instance.equals(arg), `nested undefined calendar property is always a RangeError`);
|
|
@ -1,20 +1,36 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// 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: Appropriate error thrown when argument cannot be converted to a valid string
|
||||
features: [Symbol, Temporal]
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainMonthDay
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.PlainMonthDay.from({ month: 5, day: 2 });
|
||||
const instance = new Temporal.PlainMonthDay(5, 2);
|
||||
|
||||
assert.throws(RangeError, () => instance.equals(undefined), "undefined");
|
||||
assert.throws(RangeError, () => instance.equals(null), "null");
|
||||
assert.throws(RangeError, () => instance.equals(true), "true");
|
||||
assert.throws(RangeError, () => instance.equals(""), "empty string");
|
||||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol");
|
||||
assert.throws(RangeError, () => instance.equals(1), "1");
|
||||
assert.throws(TypeError, () => instance.equals({}), "plain object");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainMonthDay), "Temporal.PlainMonthDay");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainMonthDay.prototype), "Temporal.PlainMonthDay.prototype");
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainMonthDay, "Temporal.PlainMonthDay, object"],
|
||||
[Temporal.PlainMonthDay.prototype, "Temporal.PlainMonthDay.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
// 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: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||
assert.throws(RangeError, () => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainTime.compare(arg, new Temporal.PlainTime(12, 34, 56, 987, 654, 321)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||
assert.throws(TypeError, () => Temporal.PlainTime.compare(new Temporal.PlainTime(12, 34, 56, 987, 654, 321), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||
}
|
|
@ -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.plaintime.from
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => Temporal.PlainTime.from(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => Temporal.PlainTime.from(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
|
@ -1,20 +1,36 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// 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: Appropriate error thrown when argument cannot be converted to a valid string
|
||||
features: [Symbol, Temporal]
|
||||
description: >
|
||||
Appropriate error thrown when argument cannot be converted to a valid string
|
||||
or property bag for PlainTime
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const instance = Temporal.PlainTime.from({ minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 });
|
||||
const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321);
|
||||
|
||||
assert.throws(RangeError, () => instance.equals(undefined), "undefined");
|
||||
assert.throws(RangeError, () => instance.equals(null), "null");
|
||||
assert.throws(RangeError, () => instance.equals(true), "true");
|
||||
assert.throws(RangeError, () => instance.equals(""), "empty string");
|
||||
assert.throws(TypeError, () => instance.equals(Symbol()), "symbol");
|
||||
assert.throws(RangeError, () => instance.equals(1), "1");
|
||||
assert.throws(TypeError, () => instance.equals({}), "plain object");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainTime), "Temporal.PlainTime");
|
||||
assert.throws(TypeError, () => instance.equals(Temporal.PlainTime.prototype), "Temporal.PlainTime.prototype");
|
||||
const rangeErrorTests = [
|
||||
[undefined, "undefined"],
|
||||
[null, "null"],
|
||||
[true, "boolean"],
|
||||
["", "empty string"],
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[1n, "bigint"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of rangeErrorTests) {
|
||||
assert.throws(RangeError, () => instance.equals(arg), `${description} does not convert to a valid ISO string`);
|
||||
}
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "plain object"],
|
||||
[Temporal.PlainTime, "Temporal.PlainTime, object"],
|
||||
[Temporal.PlainTime.prototype, "Temporal.PlainTime.prototype, object"],
|
||||
];
|
||||
|
||||
for (const [arg, description] of typeErrorTests) {
|
||||
assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue