Skip to content

Commit

Permalink
Temporal: Move tests for getNext/PreviousTransition into ZonedDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomato committed Jun 27, 2024
1 parent 92dfe3c commit f8c75fc
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 341 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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.zoneddatetime.prototype.gettimezonetransition
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/

const getTimeZoneTransition = Temporal.ZonedDateTime.prototype.getTimeZoneTransition;

assert.sameValue(typeof getTimeZoneTransition, "function");

const args = ["next"];

assert.throws(TypeError, () => getTimeZoneTransition.apply(undefined, args), "undefined");
assert.throws(TypeError, () => getTimeZoneTransition.apply(null, args), "null");
assert.throws(TypeError, () => getTimeZoneTransition.apply(true, args), "true");
assert.throws(TypeError, () => getTimeZoneTransition.apply("", args), "empty string");
assert.throws(TypeError, () => getTimeZoneTransition.apply(Symbol(), args), "symbol");
assert.throws(TypeError, () => getTimeZoneTransition.apply(1, args), "1");
assert.throws(TypeError, () => getTimeZoneTransition.apply({}, args), "plain object");
assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime");
assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime.prototype, args), "Temporal.ZonedDateTime.prototype");
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
description: >
Tests that Temporal.TimeZone.prototype.getPreviousTransition
Tests that Temporal.ZonedDateTime.prototype.getTimeZoneTransition
meets the requirements for built-in objects defined by the
introduction of chapter 17 of the ECMAScript Language Specification.
info: |
Expand All @@ -20,14 +20,14 @@ info: |
features: [Temporal]
---*/

assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getPreviousTransition),
assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getTimeZoneTransition),
true, "Built-in objects must be extensible.");

assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getPreviousTransition),
assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getTimeZoneTransition),
"[object Function]", "Object.prototype.toString");

assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getPreviousTransition),
assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getTimeZoneTransition),
Function.prototype, "prototype");

assert.sameValue(Temporal.TimeZone.prototype.getPreviousTransition.hasOwnProperty("prototype"),
assert.sameValue(Temporal.ZonedDateTime.prototype.getTimeZoneTransition.hasOwnProperty("prototype"),
false, "prototype property");
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Temporal.TimeZone.prototype.getPreviousTransition.length is 1
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.length is 0
info: |
Every built-in function object, including constructors, has a "length" property whose value is
an integer. Unless otherwise specified, this value is equal to the largest number of named
Expand All @@ -17,7 +17,7 @@ includes: [propertyHelper.js]
features: [Temporal]
---*/

verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "length", {
verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "length", {
value: 1,
writable: false,
enumerable: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Temporal.TimeZone.prototype.getPreviousTransition.name is "getPreviousTransition".
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.name is "getTimeZoneTransition".
info: |
Every built-in function object, including constructors, that is not identified as an anonymous
function has a "name" property whose value is a String. Unless otherwise specified, this value
Expand All @@ -15,8 +15,8 @@ includes: [propertyHelper.js]
features: [Temporal]
---*/

verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "name", {
value: "getPreviousTransition",
verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "name", {
value: "getTimeZoneTransition",
writable: false,
enumerable: false,
configurable: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition
description: >
Temporal.TimeZone.prototype.getPreviousTransition does not implement [[Construct]], is not new-able
Temporal.ZonedDateTime.prototype.getTimeZoneTransition does not implement [[Construct]], is not new-able
info: |
Built-in function objects that are not identified as constructors do not implement the
[[Construct]] internal method unless otherwise specified in the description of a particular
Expand All @@ -14,8 +14,8 @@ features: [Reflect.construct, Temporal]
---*/

assert.throws(TypeError, () => {
new Temporal.TimeZone.prototype.getPreviousTransition();
new Temporal.ZonedDateTime.prototype.getTimeZoneTransition();
}, "Calling as constructor");

assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPreviousTransition), false,
"isConstructor(Temporal.TimeZone.prototype.getPreviousTransition)");
assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), false,
"isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition)");
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.zoneddatetime.prototype.gettimezonetransition
description: The "getTimeZoneTransition" property of Temporal.ZonedDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/

assert.sameValue(
typeof Temporal.ZonedDateTime.prototype.getTimeZoneTransition,
"function",
"`typeof ZonedDateTime.prototype.getTimeZoneTransition` is `function`"
);

verifyProperty(Temporal.ZonedDateTime.prototype, "getTimeZoneTransition", {
writable: true,
enumerable: false,
configurable: true,
});

This file was deleted.

Loading

0 comments on commit f8c75fc

Please sign in to comment.