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.
This copies over the tests that previously existed in the tc39/proposal-temporal repository. For context, see thread starting at: tc39#3002 (comment) In service of tc39#3002
- Loading branch information
Showing
2,765 changed files
with
67,828 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,27 @@ | ||
// 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.calendar | ||
description: Tests that Temporal.Calendar meets the requirements for built-in objects | ||
info: | | ||
Unless specified otherwise, a built-in object that is callable as a function is a built-in | ||
function object with the characteristics described in 10.3. Unless specified otherwise, the | ||
[[Extensible]] internal slot of a built-in object initially has the value true. | ||
Unless otherwise specified every built-in function and every built-in constructor has the | ||
Function prototype object [...] as the value of its [[Prototype]] internal slot. | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.sameValue(Object.isExtensible(Temporal.Calendar), | ||
true, "Built-in objects must be extensible."); | ||
|
||
assert.sameValue(Object.prototype.toString.call(Temporal.Calendar), | ||
"[object Function]", "Object.prototype.toString"); | ||
|
||
assert.sameValue(Object.getPrototypeOf(Temporal.Calendar), | ||
Function.prototype, "prototype"); | ||
|
||
assert.sameValue(typeof Temporal.Calendar.prototype, | ||
"object", "prototype property"); |
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,12 @@ | ||
// 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.calendar | ||
description: Temporal.Calendar constructor cannot be called as a function | ||
info: | | ||
1. If NewTarget is undefined, throw a TypeError exception. | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => Temporal.Calendar()); |
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,30 @@ | ||
// 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.calendar.from | ||
description: Tests that Temporal.Calendar.from meets the requirements for built-in objects | ||
info: | | ||
Built-in functions that are not constructors do not have a "prototype" property unless | ||
otherwise specified in the description of a particular function. | ||
Unless specified otherwise, a built-in object that is callable as a function is a built-in | ||
function object with the characteristics described in 10.3. Unless specified otherwise, the | ||
[[Extensible]] internal slot of a built-in object initially has the value true. | ||
Unless otherwise specified every built-in function and every built-in constructor has the | ||
Function prototype object [...] as the value of its [[Prototype]] internal slot. | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.sameValue(Object.isExtensible(Temporal.Calendar.from), | ||
true, "Built-in objects must be extensible."); | ||
|
||
assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.from), | ||
"[object Function]", "Object.prototype.toString"); | ||
|
||
assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.from), | ||
Function.prototype, "prototype"); | ||
|
||
assert.sameValue(Temporal.Calendar.from.hasOwnProperty("prototype"), | ||
false, "prototype property"); |
11 changes: 11 additions & 0 deletions
11
test/built-ins/Temporal/Calendar/from/calendar-object-invalid.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,11 @@ | ||
// 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.calendar.from | ||
description: Converting objects to Temporal.Calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.throws(RangeError, () => Temporal.Calendar.from({ calendar: "local" })); | ||
assert.throws(RangeError, () => Temporal.Calendar.from({ calendar: { calendar: "iso8601" } })); |
39 changes: 39 additions & 0 deletions
39
test/built-ins/Temporal/Calendar/from/calendar-object-operations.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,39 @@ | ||
// 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.calendar.from | ||
description: Converting objects to Temporal.Calendar | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const expected = [ | ||
"has outer.calendar", | ||
"get outer.calendar", | ||
"has inner.calendar", | ||
"get inner.toString", | ||
"call inner.toString", | ||
]; | ||
const actual = []; | ||
const calendar = new Proxy({}, { | ||
has(t, p) { | ||
actual.push(`has outer.${p}`); | ||
return true; | ||
}, | ||
get(t, p) { | ||
actual.push(`get outer.${p}`); | ||
return new Proxy(TemporalHelpers.toPrimitiveObserver(actual, "iso8601", "inner"), { | ||
has(t, p) { | ||
actual.push(`has inner.${p}`); | ||
return true; | ||
}, | ||
get(t, p) { | ||
return t[p]; | ||
}, | ||
}); | ||
}, | ||
}); | ||
const result = Temporal.Calendar.from(calendar); | ||
assert.sameValue(result.id, "iso8601"); | ||
assert.compareArray(actual, expected); |
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) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.from | ||
description: Converting objects to Temporal.Calendar | ||
features: [Temporal] | ||
---*/ | ||
|
||
const cal = new Temporal.Calendar("iso8601"); | ||
const calFromObject = Temporal.Calendar.from({ calendar: cal }); | ||
assert(calFromObject instanceof Temporal.Calendar); | ||
assert.sameValue(calFromObject.id, "iso8601"); | ||
|
||
const calFromString = Temporal.Calendar.from({ calendar: "iso8601" }); | ||
assert(calFromString instanceof Temporal.Calendar); | ||
assert.sameValue(calFromString.id, "iso8601"); | ||
|
||
const custom = { id: "custom-calendar" }; | ||
assert.sameValue(Temporal.Calendar.from({ calendar: custom }), custom); | ||
assert.sameValue(Temporal.Calendar.from(custom), custom); |
19 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/Calendar/from/calendar-string-builtin.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,19 @@ | ||
// 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.calendar.from | ||
description: Calendar.from should support iso8601. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
"iso8601", | ||
"1994-11-05T08:15:30-05:00", | ||
]; | ||
|
||
for (const item of tests) { | ||
const calendar = Temporal.Calendar.from(item); | ||
assert(calendar instanceof Temporal.Calendar); | ||
assert.sameValue(calendar.id, "iso8601"); | ||
} |
19 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/Calendar/from/calendar-string-not-builtin.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,19 @@ | ||
// 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.calendar.from | ||
description: from() throws if the argument is not a built-in calendar name. | ||
features: [Temporal] | ||
---*/ | ||
|
||
const tests = [ | ||
"local", | ||
"iso-8601", | ||
"[u-ca=iso8601]", | ||
"invalid-calendar", | ||
]; | ||
|
||
for (const item of tests) { | ||
assert.throws(RangeError, () => Temporal.Calendar.from(item)); | ||
} |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/Calendar/from/calendar-temporal-object.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,20 @@ | ||
// 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.calendar.from | ||
description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots | ||
info: | | ||
sec-temporal.calendar.from step 1: | ||
1. Return ? ToTemporalCalendar(_item_). | ||
sec-temporal-totemporalcalendar step 1.a: | ||
a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then | ||
i. Return _temporalCalendarLike_.[[Calendar]]. | ||
includes: [compareArray.js, temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { | ||
const newCalendar = Temporal.Calendar.from(temporalObject); | ||
assert.sameValue(newCalendar, calendar, "calendar object retrieved from internal slot"); | ||
}); |
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) 2020 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.from | ||
description: Temporal.Calendar.from.length is 1 | ||
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 | ||
arguments shown in the subclause headings for the function description. Optional parameters | ||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form | ||
«...name») are not included in the default argument count. | ||
Unless otherwise specified, the "length" property of a built-in function object has the | ||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
verifyProperty(Temporal.Calendar.from, "length", { | ||
value: 1, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
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,23 @@ | ||
// 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.calendar.from | ||
description: Temporal.Calendar.from.name is "from" | ||
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 | ||
is the name that is given to the function in this specification. | ||
Unless otherwise specified, the "name" property of a built-in function object, if it exists, | ||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
verifyProperty(Temporal.Calendar.from, "name", { | ||
value: "from", | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
20 changes: 20 additions & 0 deletions
20
test/built-ins/Temporal/Calendar/from/not-a-constructor.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,20 @@ | ||
// 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.calendar.from | ||
description: Temporal.Calendar.from 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 | ||
function. | ||
includes: [isConstructor.js] | ||
features: [Reflect.construct, Temporal] | ||
---*/ | ||
|
||
assert.throws(TypeError, () => { | ||
new Temporal.Calendar.from(); | ||
}, "Calling as constructor"); | ||
|
||
assert.sameValue(isConstructor(Temporal.Calendar.from), false, | ||
"isConstructor(Temporal.Calendar.from)"); |
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) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.from | ||
description: The "from" property of Temporal.Calendar | ||
includes: [propertyHelper.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.sameValue( | ||
typeof Temporal.Calendar.from, | ||
"function", | ||
"`typeof Calendar.from` is `function`" | ||
); | ||
|
||
verifyProperty(Temporal.Calendar, "from", { | ||
writable: true, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
19 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/Calendar/from/subclassing-ignored.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,19 @@ | ||
// 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.calendar.from | ||
description: The receiver is never called when calling from() | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
TemporalHelpers.checkSubclassingIgnoredStatic( | ||
Temporal.Calendar, | ||
"from", | ||
["iso8601"], | ||
(result) => { | ||
assert.sameValue(result.id, "iso8601", "id property of result"); | ||
assert.sameValue(result.toString(), "iso8601", "toString() of result"); | ||
}, | ||
); |
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) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar | ||
description: Temporal.Calendar.length is 1 | ||
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 | ||
arguments shown in the subclause headings for the function description. Optional parameters | ||
(which are indicated with brackets: [ ]) or rest parameters (which are shown using the form | ||
«...name») are not included in the default argument count. | ||
Unless otherwise specified, the "length" property of a built-in function object has the | ||
attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
verifyProperty(Temporal.Calendar, "length", { | ||
value: 1, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
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,11 @@ | ||
// 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.calendar | ||
description: RangeError thrown when constructor invoked with no argument | ||
features: [Temporal] | ||
---*/ | ||
|
||
assert.throws(RangeError, () => new Temporal.Calendar()); | ||
assert.throws(RangeError, () => new Temporal.Calendar(undefined)); |
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,23 @@ | ||
// 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.calendar | ||
description: Temporal.Calendar.name is "Calendar" | ||
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 | ||
is the name that is given to the function in this specification. | ||
Unless otherwise specified, the "name" property of a built-in function object, if it exists, | ||
has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
verifyProperty(Temporal.Calendar, "name", { | ||
value: "Calendar", | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); |
Oops, something went wrong.