forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Add tests covering options bag argument of getTimeZoneTrans…
…ition
- Loading branch information
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 18 additions & 0 deletions
18
.../built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 15 additions & 0 deletions
15
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 25 additions & 0 deletions
25
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} |