diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js new file mode 100644 index 0000000000..a1cacf2be8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js @@ -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 })); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js new file mode 100644 index 0000000000..8a250c6b2c --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js @@ -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"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js new file mode 100644 index 0000000000..eaec7462ff --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js @@ -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)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js new file mode 100644 index 0000000000..ff0ee1151b --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js @@ -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 })); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js new file mode 100644 index 0000000000..33a6731e4e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js @@ -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)); +}