mirror of
https://github.com/tc39/test262.git
synced 2025-05-11 18:30:31 +02:00
Tests disallowed smallest and largest unit arguments to PYM.since
This commit is contained in:
parent
927ad3051f
commit
9c6ecf5326
24
test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-disallowed-units.js
vendored
Normal file
24
test/built-ins/Temporal/PlainYearMonth/prototype/since/largestunit-disallowed-units.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plainyearmonth.prototype.since
|
||||||
|
description: Since throws on to0-small largestUnit
|
||||||
|
features: [Temporal, arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const earlier = new Temporal.PlainYearMonth(2019, 1);
|
||||||
|
const later = new Temporal.PlainYearMonth(2021, 9);
|
||||||
|
|
||||||
|
[
|
||||||
|
'weeks',
|
||||||
|
'days',
|
||||||
|
'hours',
|
||||||
|
'minutes',
|
||||||
|
'seconds',
|
||||||
|
'milliseconds',
|
||||||
|
'microseconds',
|
||||||
|
'nanoseconds'
|
||||||
|
].forEach((largestUnit) => {
|
||||||
|
assert.throws(RangeError, () => later.since(earlier, { largestUnit }),`throws on disallowed or invalid largestUnit: ${largestUnit}`);
|
||||||
|
});
|
28
test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-disallowed-units.js
vendored
Normal file
28
test/built-ins/Temporal/PlainYearMonth/prototype/since/smallestunit-disallowed-units.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-temporal.plainyearmonth.prototype.since
|
||||||
|
description: Since throws on disallowed or invalid smallestUnit
|
||||||
|
features: [Temporal, arrow-function]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const earlier = new Temporal.PlainYearMonth(2019, 1);
|
||||||
|
const later = new Temporal.PlainYearMonth(2021, 9);
|
||||||
|
|
||||||
|
[
|
||||||
|
'era',
|
||||||
|
'weeks',
|
||||||
|
'days',
|
||||||
|
'hours',
|
||||||
|
'minutes',
|
||||||
|
'seconds',
|
||||||
|
'milliseconds',
|
||||||
|
'microseconds',
|
||||||
|
'nanoseconds',
|
||||||
|
'nonsense'
|
||||||
|
].forEach((smallestUnit) => {
|
||||||
|
assert.throws(RangeError, () => later.since(earlier, { smallestUnit }),`throws on disallowed or invalid smallestUnit: ${smallestUnit}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(RangeError, () => later.since(earlier, { largestUnit: 'months', smallestUnit: 'years' }), 'throws if smallestUnit is larger than largestUnit');
|
Loading…
x
Reference in New Issue
Block a user