Skip to content

Commit

Permalink
Split Array.prototype.Symbol.unscopables tests for features
Browse files Browse the repository at this point in the history
  • Loading branch information
legendecas authored and rwaldron committed Mar 10, 2022
1 parent d8fb00d commit 50dc96e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2022 Microsoft. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype-@@unscopables
description: >
Initial value of `Symbol.unscopables` property
info: |
22.1.3.32 Array.prototype [ @@unscopables ]
...
7. Perform CreateDataProperty(unscopableList, "findLast", true).
8. Perform CreateDataProperty(unscopableList, "findLastIndex", true).
...
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-find-from-last]
---*/

var unscopables = Array.prototype[Symbol.unscopables];

assert.sameValue(Object.getPrototypeOf(unscopables), null);

assert.sameValue(unscopables.findLast, true, '`findLast` property value');
verifyEnumerable(unscopables, 'findLast');
verifyWritable(unscopables, 'findLast');
verifyConfigurable(unscopables, 'findLast');

assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value');
verifyEnumerable(unscopables, 'findLastIndex');
verifyWritable(unscopables, 'findLastIndex');
verifyConfigurable(unscopables, 'findLastIndex');
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype-@@unscopables
description: >
Initial value of `Symbol.unscopables` property
info: |
22.1.3.32 Array.prototype [ @@unscopables ]
...
10. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupBy", true).
11. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupByToMap", true).
...
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-grouping]
---*/

var unscopables = Array.prototype[Symbol.unscopables];

assert.sameValue(Object.getPrototypeOf(unscopables), null);

assert.sameValue(unscopables.groupBy, true, '`groupBy` property value');
verifyEnumerable(unscopables, 'groupBy');
verifyWritable(unscopables, 'groupBy');
verifyConfigurable(unscopables, 'groupBy');

assert.sameValue(unscopables.groupByToMap, true, '`groupByToMap` property value');
verifyEnumerable(unscopables, 'groupByToMap');
verifyWritable(unscopables, 'groupByToMap');
verifyConfigurable(unscopables, 'groupByToMap');
42 changes: 9 additions & 33 deletions test/built-ins/Array/prototype/Symbol.unscopables/value.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,16 @@ info: |
4. Perform CreateDataProperty(unscopableList, "fill", true).
5. Perform CreateDataProperty(unscopableList, "find", true).
6. Perform CreateDataProperty(unscopableList, "findIndex", true).
7. Perform CreateDataProperty(unscopableList, "findLast", true).
8. Perform CreateDataProperty(unscopableList, "findLastIndex", true).
9. Perform CreateDataProperty(unscopableList, "flat", true).
10. Perform CreateDataProperty(unscopableList, "flatMap", true).
11. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupBy", true).
12. Perform ! CreateDataPropertyOrThrow(unscopableList, "groupByToMap", true).
13. Perform CreateDataProperty(unscopableList, "includes", true).
14. Perform CreateDataProperty(unscopableList, "keys", true).
15. Perform CreateDataProperty(unscopableList, "values", true).
16. Assert: Each of the above calls returns true.
17. Return unscopableList.
7. Perform CreateDataProperty(unscopableList, "flat", true).
8. Perform CreateDataProperty(unscopableList, "flatMap", true).
9. Perform CreateDataProperty(unscopableList, "includes", true).
10. Perform CreateDataProperty(unscopableList, "keys", true).
11. Perform CreateDataProperty(unscopableList, "values", true).
12. Assert: Each of the above calls returns true.
13. Return unscopableList.
includes: [propertyHelper.js]
features: [Symbol.unscopables, array-find-from-last, array-grouping]
features: [Symbol.unscopables]
---*/

var unscopables = Array.prototype[Symbol.unscopables];
Expand Down Expand Up @@ -57,17 +54,6 @@ verifyEnumerable(unscopables, 'findIndex');
verifyWritable(unscopables, 'findIndex');
verifyConfigurable(unscopables, 'findIndex');


assert.sameValue(unscopables.findLast, true, '`findLast` property value');
verifyEnumerable(unscopables, 'findLast');
verifyWritable(unscopables, 'findLast');
verifyConfigurable(unscopables, 'findLast');

assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value');
verifyEnumerable(unscopables, 'findLastIndex');
verifyWritable(unscopables, 'findLastIndex');
verifyConfigurable(unscopables, 'findLastIndex');

assert.sameValue(unscopables.flat, true, '`flat` property value');
verifyEnumerable(unscopables, 'flat');
verifyWritable(unscopables, 'flat');
Expand All @@ -78,16 +64,6 @@ verifyEnumerable(unscopables, 'flatMap');
verifyWritable(unscopables, 'flatMap');
verifyConfigurable(unscopables, 'flatMap');

assert.sameValue(unscopables.groupBy, true, '`groupBy` property value');
verifyEnumerable(unscopables, 'groupBy');
verifyWritable(unscopables, 'groupBy');
verifyConfigurable(unscopables, 'groupBy');

assert.sameValue(unscopables.groupByToMap, true, '`groupByToMap` property value');
verifyEnumerable(unscopables, 'groupByToMap');
verifyWritable(unscopables, 'groupByToMap');
verifyConfigurable(unscopables, 'groupByToMap');

assert.sameValue(unscopables.includes, true, '`includes` property value');
verifyEnumerable(unscopables, 'includes');
verifyWritable(unscopables, 'includes');
Expand Down

0 comments on commit 50dc96e

Please sign in to comment.