mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 05:55:36 +02:00
Temporal: Add tests covering options bag argument of getTimeZoneTransition
This commit is contained in:
parent
c22fbc7b45
commit
73f85aeeaf
14
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js
vendored
Normal file
14
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
|
||||
description: If using options bag form, direction property is required
|
||||
info: |
|
||||
1. Let _direction_ be ? GetDirectionOption(_directionParam_).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
assert.throws(RangeError, () => zdt.getTimeZoneTransition({}));
|
||||
assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: undefined }));
|
18
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js
vendored
Normal file
18
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
|
||||
description: Value of direction property cannot be a primitive other than string
|
||||
info: |
|
||||
1. Let _direction_ be ? GetDirectionOption(_directionParam_).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const rangeErrorValues = [false, 42, 55n, null];
|
||||
for (const badValue of rangeErrorValues) {
|
||||
assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: badValue }), "Non-Symbol throws a RangeError");
|
||||
}
|
||||
assert.throws(TypeError, () => zdt.getTimeZoneTransition({ direction: Symbol("next") }), "Symbol throws a TypeError");
|
15
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js
vendored
Normal file
15
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
|
||||
description: Options argument is required
|
||||
info: |
|
||||
1. If _directionParam_ is *undefined*, throw a *TypeError* exception.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
assert.throws(TypeError, () => zdt.getTimeZoneTransition());
|
||||
assert.throws(TypeError, () => zdt.getTimeZoneTransition(undefined));
|
25
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js
vendored
Normal file
25
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
|
||||
description: >
|
||||
Shorthand form is treated the same as options bag form with respect to
|
||||
incorrect strings
|
||||
info: |
|
||||
1. If _directionParam_ is a String, then
|
||||
1. Let _paramString_ be _directionParam_.
|
||||
1. Set _roundTo_ to OrdinaryObjectCreate(*null*).
|
||||
1. Perform ! CreateDataPropertyOrThrow(_directionParam_, *"direction"*, _paramString_).
|
||||
...
|
||||
1. Let _direction_ be ? GetDirectionOption(_directionParam_).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const badStrings = ['PREVIOUS', 'following', 'next\0', 'prevıous'];
|
||||
for (const badString of badStrings) {
|
||||
assert.throws(RangeError, () => zdt.getTimeZoneTransition(badString));
|
||||
assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: badString }));
|
||||
}
|
21
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js
vendored
Normal file
21
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
|
||||
description: >
|
||||
Options bag cannot be anything other than a string, an object, or undefined
|
||||
info: |
|
||||
1. If _directionParam_ is a String, then
|
||||
...
|
||||
1. Else,
|
||||
1. Set _directionParam_ to ? GetOptionsObject(_directionParam_).
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
|
||||
const badValues = [false, 42, 55n, Symbol("foo"), null];
|
||||
for (const badValue of badValues) {
|
||||
assert.throws(TypeError, () => zdt.getTimeZoneTransition(badValue));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user