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 May 25, 2024
1 parent e98b5a0 commit 3168bc7
Show file tree
Hide file tree
Showing 24 changed files with 237 additions and 259 deletions.

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.nexttransition
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/

const nextTransition = Temporal.ZonedDateTime.prototype.nextTransition;

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

const args = [];

assert.throws(TypeError, () => nextTransition.apply(undefined, args), "undefined");
assert.throws(TypeError, () => nextTransition.apply(null, args), "null");
assert.throws(TypeError, () => nextTransition.apply(true, args), "true");
assert.throws(TypeError, () => nextTransition.apply("", args), "empty string");
assert.throws(TypeError, () => nextTransition.apply(Symbol(), args), "symbol");
assert.throws(TypeError, () => nextTransition.apply(1, args), "1");
assert.throws(TypeError, () => nextTransition.apply({}, args), "plain object");
assert.throws(TypeError, () => nextTransition.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime");
assert.throws(TypeError, () => nextTransition.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.getnexttransition
esid: sec-temporal.zoneddatetime.prototype.nexttransition
description: >
Tests that Temporal.TimeZone.prototype.getNextTransition
Tests that Temporal.ZonedDateTime.prototype.nextTransition
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.getNextTransition),
assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.nextTransition),
true, "Built-in objects must be extensible.");

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

assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getNextTransition),
assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.nextTransition),
Function.prototype, "prototype");

assert.sameValue(Temporal.TimeZone.prototype.getNextTransition.hasOwnProperty("prototype"),
assert.sameValue(Temporal.ZonedDateTime.prototype.nextTransition.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.getnexttransition
description: Temporal.TimeZone.prototype.getNextTransition.length is 1
esid: sec-temporal.zoneddatetime.prototype.nexttransition
description: Temporal.ZonedDateTime.prototype.nextTransition.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,8 +17,8 @@ includes: [propertyHelper.js]
features: [Temporal]
---*/

verifyProperty(Temporal.TimeZone.prototype.getNextTransition, "length", {
value: 1,
verifyProperty(Temporal.ZonedDateTime.prototype.nextTransition, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
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.getnexttransition
description: Temporal.TimeZone.prototype.getNextTransition.name is "getNextTransition".
esid: sec-temporal.zoneddatetime.prototype.nexttransition
description: Temporal.ZonedDateTime.prototype.nextTransition.name is "nextTransition".
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.getNextTransition, "name", {
value: "getNextTransition",
verifyProperty(Temporal.ZonedDateTime.prototype.nextTransition, "name", {
value: "nextTransition",
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.getnexttransition
esid: sec-temporal.zoneddatetime.prototype.nexttransition
description: >
Temporal.TimeZone.prototype.getNextTransition does not implement [[Construct]], is not new-able
Temporal.ZonedDateTime.prototype.nextTransition 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.getNextTransition();
new Temporal.ZonedDateTime.prototype.nextTransition();
}, "Calling as constructor");

assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getNextTransition), false,
"isConstructor(Temporal.TimeZone.prototype.getNextTransition)");
assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.nextTransition), false,
"isConstructor(Temporal.ZonedDateTime.prototype.nextTransition)");
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.nexttransition
description: The "nextTransition" property of Temporal.ZonedDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/

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

verifyProperty(Temporal.ZonedDateTime.prototype, "nextTransition", {
writable: true,
enumerable: false,
configurable: true,
});
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.previoustransition
description: Throw a TypeError if the receiver is invalid
features: [Symbol, Temporal]
---*/

const previousTransition = Temporal.ZonedDateTime.prototype.previousTransition;

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

const args = [];

assert.throws(TypeError, () => previousTransition.apply(undefined, args), "undefined");
assert.throws(TypeError, () => previousTransition.apply(null, args), "null");
assert.throws(TypeError, () => previousTransition.apply(true, args), "true");
assert.throws(TypeError, () => previousTransition.apply("", args), "empty string");
assert.throws(TypeError, () => previousTransition.apply(Symbol(), args), "symbol");
assert.throws(TypeError, () => previousTransition.apply(1, args), "1");
assert.throws(TypeError, () => previousTransition.apply({}, args), "plain object");
assert.throws(TypeError, () => previousTransition.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime");
assert.throws(TypeError, () => previousTransition.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.previoustransition
description: >
Tests that Temporal.TimeZone.prototype.getPreviousTransition
Tests that Temporal.ZonedDateTime.prototype.previousTransition
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.previousTransition),
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.previousTransition),
"[object Function]", "Object.prototype.toString");

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

assert.sameValue(Temporal.TimeZone.prototype.getPreviousTransition.hasOwnProperty("prototype"),
assert.sameValue(Temporal.ZonedDateTime.prototype.previousTransition.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.previoustransition
description: Temporal.ZonedDateTime.prototype.previousTransition.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,8 +17,8 @@ includes: [propertyHelper.js]
features: [Temporal]
---*/

verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "length", {
value: 1,
verifyProperty(Temporal.ZonedDateTime.prototype.previousTransition, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true,
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.previoustransition
description: Temporal.ZonedDateTime.prototype.previousTransition.name is "previousTransition".
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.previousTransition, "name", {
value: "previousTransition",
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.previoustransition
description: >
Temporal.TimeZone.prototype.getPreviousTransition does not implement [[Construct]], is not new-able
Temporal.ZonedDateTime.prototype.previousTransition 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.previousTransition();
}, "Calling as constructor");

assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPreviousTransition), false,
"isConstructor(Temporal.TimeZone.prototype.getPreviousTransition)");
assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.previousTransition), false,
"isConstructor(Temporal.ZonedDateTime.prototype.previousTransition)");
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.previoustransition
description: The "previousTransition" property of Temporal.ZonedDateTime.prototype
includes: [propertyHelper.js]
features: [Temporal]
---*/

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

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

0 comments on commit 3168bc7

Please sign in to comment.