Skip to content

Commit

Permalink
Add Array.prototype.includes and exponentiation features (#3799)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 authored Mar 23, 2023
1 parent 9704d7f commit 4a6439e
Show file tree
Hide file tree
Showing 173 changed files with 175 additions and 83 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ includes: [asyncHelpers.js]
asyncTest(async function() {
await assert.throwsAsync(TypeError, () => Array.fromAsync([], "not a function"), "Array.fromAsync should reject asynchronously");
});
```

## A Note on Python-based tools

Expand Down
2 changes: 2 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ ArrayBuffer
Array.prototype.at
Array.prototype.flat
Array.prototype.flatMap
Array.prototype.includes
Array.prototype.values
arrow-function
async-iteration
Expand Down Expand Up @@ -148,6 +149,7 @@ destructuring-assignment
destructuring-binding
dynamic-import
error-cause
exponentiation
export-star-as-namespace-from-module # https://github.com/tc39/ecma262/pull/1174
FinalizationRegistry
for-in-order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
UpdateExpression ** ExponentiationExpression
Static Semantics AssignmentTargetType, Return invalid.
template: invalid
features: [exponentiation]
negative:
phase: parse
type: SyntaxError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
UpdateExpression ** ExponentiationExpression
Static Semantics AssignmentTargetType, Return invalid.
template: invalid
features: [exponentiation]
negative:
phase: parse
type: SyntaxError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
UpdateExpression ** ExponentiationExpression
Static Semantics AssignmentTargetType, Return invalid.
template: invalid
features: [exponentiation]
negative:
phase: parse
type: SyntaxError
Expand Down
1 change: 1 addition & 0 deletions src/compound-assignment-private/exp.case
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/*---
template: default
desc: Compound exponentiation assignment with target being a private reference
features: [exponentiation]
---*/

//- lhs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*---
desc: Computed property name from exponentiation expression
template: evaluation
features: [computed-property-names]
features: [computed-property-names, exponentiation]
---*/

//- ComputedPropertyName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*---
desc: Computed property name from math
template: evaluation
features: [computed-property-names]
features: [computed-property-names, exponentiation]
---*/
//- ComputedPropertyName
1 + 2 - 3 * 4 / 5 ** 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/*---
esid: sec-array.prototype.includes
description: Array.prototype.includes applied to boolean primitive
features: [Array.prototype.includes]
---*/

assert.sameValue(Array.prototype.includes.call(true), false, 'Array.prototype.includes.call(true) must return false');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ info: |
7. Repeat, while k < len
...
8. Return false.
features: [Array.prototype.includes]
---*/

var sample = [7, 7, 7, 7];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ info: |
7. Repeat, while k < len
...
8. Return false.
features: [Array.prototype.includes]
---*/

var sample = [42, 43, 43, 41];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ info: |
...
7. Repeat, while k < len
...
features: [Array.prototype.includes]
---*/

var sample = [42, 43];
Expand Down
2 changes: 1 addition & 1 deletion test/built-ins/Array/prototype/includes/get-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ info: |
a. Let elementK be the result of ? Get(O, ! ToString(k)).
...
includes: [compareArray.js]
features: [Proxy]
features: [Proxy, Array.prototype.includes]
---*/

var calls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ info: |
2. If len ≤ +0, return +0.
3. If len is +∞, return 2**53-1.
4. Return min(len, 2**53-1).
features: [Array.prototype.includes]
---*/

var obj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ info: |
2. Let len be ? ToLength(? Get(O, "length")).
3. If len is 0, return false.
...
features: [Array.prototype.includes]
---*/

var calls = 0;
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/length.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ info: |
object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
[[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Array.prototype.includes]
---*/

assert.sameValue(Array.prototype.includes.length, 1);
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/name.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ info: |
object, if it exists, has the attributes { [[Writable]]: false,
[[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Array.prototype.includes]
---*/

assert.sameValue(Array.prototype.includes.name, "includes");
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/no-arg.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
...
features: [Array.prototype.includes]
---*/

assert.sameValue([0].includes(), false, "[0].includes()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info: |
7. If IsConstructor(constructor) is false, throw a TypeError exception.
...
includes: [isConstructor.js]
features: [Reflect.construct, arrow-function]
features: [Reflect.construct, arrow-function, Array.prototype.includes]
---*/

assert.sameValue(
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/prop-desc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
and in Annex B.2 has the attributes { [[Writable]]: true,
[[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Array.prototype.includes]
---*/

verifyNotEnumerable(Array.prototype, "includes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ info: |
...
2. Let len be ? ToLength(? Get(O, "length")).
...
features: [Array.prototype.includes]
---*/

var obj = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ info: |
7. Repeat, while k < len
a. Let elementK be the result of ? Get(O, ! ToString(k)).
...
features: [Array.prototype.includes]
---*/

var stopped = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ info: |
4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
produces the value 0.)
...
features: [Symbol]
features: [Symbol, Array.prototype.includes]
---*/

var fromIndex = Symbol("1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ info: |
4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step
produces the value 0.)
...
features: [Array.prototype.includes]
---*/

var fromIndex = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ info: |
...
2. Let len be ? ToLength(? Get(O, "length")).
...
features: [Symbol]
features: [Symbol, Array.prototype.includes]
---*/

var obj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ info: |
...
2. Let len be ? ToLength(? Get(O, "length")).
...
features: [Array.prototype.includes]
---*/

var obj1 = {
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/samevaluezero.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
...
features: [Array.prototype.includes]
---*/

var sample = [42, 0, 1, NaN];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
...
features: [Symbol]
features: [Symbol, Array.prototype.includes]
---*/

var symbol = Symbol("1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
8. Return false.
features: [Symbol]
features: [Symbol, Array.prototype.includes]
---*/

assert.sameValue([42].includes(43), false, "43");
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/sparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
...
features: [Array.prototype.includes]
---*/

assert.sameValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
1. Let O be ? ToObject(this value).
...
features: [Array.prototype.includes]
---*/

var includes = Array.prototype.includes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
8. Return false.
features: [Array.prototype.includes]
---*/

var obj = {
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/tolength-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ info: |
2. If len ≤ +0, return +0.
3. If len is +∞, return 253-1.
4. Return min(len, 253-1).
features: [Array.prototype.includes]
---*/

var obj = {
Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Array/prototype/includes/using-fromindex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ info: |
b. If SameValueZero(searchElement, elementK) is true, return true.
c. Increase k by 1.
...
features: [Array.prototype.includes]
---*/

var sample = ["a", "b", "c"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ info: |
7. Repeat, while k < len
a. Let elementK be the result of ? Get(O, ! ToString(k)).
...
features: [Array.prototype.includes]
---*/

function getCleanObj() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ info: |
Argument Type: Undefined
Result: Throw a TypeError exception.
features: [Symbol, Symbol.isConcatSpreadable, Symbol.iterator, Symbol.species, Array.prototype.flat, Array.prototype.flatMap]
features: [Symbol, Symbol.isConcatSpreadable, Symbol.iterator, Symbol.species, Array.prototype.flat, Array.prototype.flatMap, Array.prototype.includes]
---*/

["constructor", "length", "0", Symbol.isConcatSpreadable, Symbol.species].forEach(function(key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ info: |
...
e. Perform ? Set(O, "length", newLen, true).
...
features: [exponentiation]
---*/

var arrayLike = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ info: |
c. Let element be ? Get(O, index).
d. Perform ? DeletePropertyOrThrow(O, index).
e. Perform ? Set(O, "length", newLen, true).
f. Return element.
f. Return element.
features: [exponentiation]
---*/

var arrayLike = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ info: |
...
7. Perform ? Set(O, "length", len, true).
...
features: [exponentiation]
---*/

var arrayLike = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ info: |
...
7. Perform ? Set(O, "length", len, true).
...
features: [exponentiation]
---*/

var arrayLike = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ info: |
4. Let argCount be the number of elements in items.
5. If len + argCount > 2^53-1, throw a TypeError exception.
...
features: [exponentiation]
---*/

var arrayLike = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ info: |
...
2. Let len be ? ToLength(? Get(O, "length")).
...
features: [exponentiation]
---*/

function StopReverse() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ esid: sec-array.prototype.reverse
description: >
Ensure correct MOP operations are called when length exceeds 2^53-1.
includes: [compareArray.js, proxyTrapsHelper.js]
features: [exponentiation]
---*/

function StopReverse() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ info: |
else let final be min(relativeEnd, len).
...
includes: [compareArray.js]
features: [exponentiation]
---*/

var array = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ info: |
else let final be min(relativeEnd, len).
...
includes: [compareArray.js]
features: [exponentiation]
---*/

var arrayLike = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ info: |
...
19. Perform ? Set(O, "length", len - actualDeleteCount + itemCount, true).
...
features: [exponentiation]
---*/

var arrayLike = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ info: |
12. Perform ? Set(A, "length", actualDeleteCount, true).
...
includes: [compareArray.js, proxyTrapsHelper.js]
features: [Symbol.species]
features: [Symbol.species, exponentiation]
---*/

function StopSplice() {}
Expand Down
Loading

0 comments on commit 4a6439e

Please sign in to comment.