mirror of https://github.com/tc39/test262.git
Add test for abrupt completion for dateAdd
This commit is contained in:
parent
6c077667fc
commit
c0b3a5f074
16
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDate.js
vendored
Normal file
16
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDate.js
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.dateadd
|
||||
description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalDate.
|
||||
info: |
|
||||
...
|
||||
4. Set date to ? ToTemporalDate(date).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.throws(RangeError,
|
||||
() => cal.dateAdd("invalid date string", new Temporal.Duration(1)),
|
||||
"Throw by 4. Set date to ? ToTemporalDate(date)");
|
16
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDuration.js
vendored
Normal file
16
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDuration.js
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.dateadd
|
||||
description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalDuration.
|
||||
info: |
|
||||
...
|
||||
5. Set duration to ? ToTemporalDuration(duration).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.throws(RangeError,
|
||||
() => cal.dateAdd("2020-02-03", "invalid duration string"),
|
||||
"Throw by ToTemporalDuration");
|
15
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js
vendored
Normal file
15
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalOverflow.js
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.dateadd
|
||||
description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalOverflow.
|
||||
info: |
|
||||
7. Let overflow be ? ToTemporalOverflow(options).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
assert.throws(RangeError,
|
||||
() => cal.dateAdd("2020-02-29", "PT1M", {overflow: "bad value"}),
|
||||
"Bad value in overflow option should throw RangeError");
|
20
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-GetOptionsObject.js
vendored
Normal file
20
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-GetOptionsObject.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.dateadd
|
||||
description: Temporal.Calendar.prototype.dateAdd should throw from GetOptionsObject.
|
||||
info: |
|
||||
...
|
||||
6. Set options to ? GetOptionsObject(options).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
let invalidOptionsList =
|
||||
[null, "invalid option", 234, 23n, Symbol("foo"), true, false, Infinity];
|
||||
|
||||
invalidOptionsList.forEach(function(invalidOptions) {
|
||||
assert.throws(TypeError,
|
||||
() => cal.dateAdd("2020-02-03", "P1Y", invalidOptions),
|
||||
"Throw by GetOptionsObject");
|
||||
});
|
17
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-RequireInternalSlot.js
vendored
Normal file
17
test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-RequireInternalSlot.js
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.calendar.prototype.dateadd
|
||||
description: Temporal.Calendar.prototype.dateAdd should throw if calendar does not have required internal slot
|
||||
info: |
|
||||
1. Let calendar be the this value.
|
||||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
let cal = new Temporal.Calendar("iso8601");
|
||||
|
||||
let badCal = { dateAdd: cal.dateAdd };
|
||||
assert.throws(TypeError,
|
||||
() => badCal.dateAdd("2020-02-29", new Temporal.Duration(1)),
|
||||
"No [[InitializedTemporalCalendar]]");
|
Loading…
Reference in New Issue