mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Rename item() to at().
This commit is contained in:
parent
36d2d2d348
commit
df1bce9c2e
@ -189,9 +189,9 @@ Atomics.waitAsync
|
|||||||
|
|
||||||
# Item Method
|
# Item Method
|
||||||
# https://github.com/tc39/proposal-item-method
|
# https://github.com/tc39/proposal-item-method
|
||||||
Array.prototype.item
|
Array.prototype.at
|
||||||
String.prototype.item
|
String.prototype.at
|
||||||
TypedArray.prototype.item
|
TypedArray.prototype.at
|
||||||
|
|
||||||
# Arbitrary module namespace names
|
# Arbitrary module namespace names
|
||||||
# https://github.com/tc39/ecma262/pull/2154
|
# https://github.com/tc39/ecma262/pull/2154
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-array.prototype.item
|
esid: sec-array.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
Array.prototype.item( index )
|
Array.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
features: [Array.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
let valueOfCallCount = 0;
|
let valueOfCallCount = 0;
|
||||||
let index = {
|
let index = {
|
||||||
@ -23,5 +23,5 @@ let index = {
|
|||||||
|
|
||||||
let a = [0,1,2,3];
|
let a = [0,1,2,3];
|
||||||
|
|
||||||
assert.sameValue(a.item(index), 1, 'a.item({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
||||||
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
@ -1,20 +1,20 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-array.prototype.item
|
esid: sec-array.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
Array.prototype.item( index )
|
Array.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
features: [Array.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
let a = [0,1,2,3];
|
let a = [0,1,2,3];
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
a.item(Symbol());
|
a.at(Symbol());
|
||||||
}, '`a.item(Symbol())` throws TypeError');
|
}, '`a.at(Symbol())` throws TypeError');
|
26
test/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
26
test/built-ins/Array/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: |
|
||||||
|
Array.prototype.at( index )
|
||||||
|
|
||||||
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
|
let a = [0,1,2,3];
|
||||||
|
|
||||||
|
assert.sameValue(a.at(false), 0, 'a.at(false) must return 0');
|
||||||
|
assert.sameValue(a.at(null), 0, 'a.at(null) must return 0');
|
||||||
|
assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0');
|
||||||
|
assert.sameValue(a.at(""), 0, 'a.at("") must return 0');
|
||||||
|
assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0');
|
||||||
|
assert.sameValue(a.at([]), 0, 'a.at([]) must return 0');
|
||||||
|
|
||||||
|
assert.sameValue(a.at(true), 1, 'a.at(true) must return 1');
|
||||||
|
assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1');
|
24
test/built-ins/Array/prototype/at/length.js
vendored
Normal file
24
test/built-ins/Array/prototype/at/length.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Array.prototype.at.length value and descriptor.
|
||||||
|
info: |
|
||||||
|
Array.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Array.prototype.at.length, 1,
|
||||||
|
'The value of Array.prototype.at.length is 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Array.prototype.at, 'length');
|
||||||
|
verifyNotWritable(Array.prototype.at, 'length');
|
||||||
|
verifyConfigurable(Array.prototype.at, 'length');
|
24
test/built-ins/Array/prototype/at/name.js
vendored
Normal file
24
test/built-ins/Array/prototype/at/name.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Array.prototype.at.name value and descriptor.
|
||||||
|
info: |
|
||||||
|
Array.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
Array.prototype.at.name, 'item',
|
||||||
|
'The value of Array.prototype.at.name is "item"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(Array.prototype.at, 'name');
|
||||||
|
verifyNotWritable(Array.prototype.at, 'name');
|
||||||
|
verifyConfigurable(Array.prototype.at, 'name');
|
@ -1,22 +1,22 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-array.prototype.item
|
esid: sec-array.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
Array.prototype.item( index )
|
Array.prototype.at( index )
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [Array.prototype.item]
|
features: [Array.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof Array.prototype.item,
|
typeof Array.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof Array.prototype.item` is "function"'
|
'The value of `typeof Array.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
verifyNotEnumerable(Array.prototype, 'item');
|
verifyNotEnumerable(Array.prototype, 'item');
|
22
test/built-ins/Array/prototype/at/return-abrupt-from-this.js
vendored
Normal file
22
test/built-ins/Array/prototype/at/return-abrupt-from-this.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Return abrupt from ToObject(this value).
|
||||||
|
info: |
|
||||||
|
Array.prototype.at( index )
|
||||||
|
|
||||||
|
Let O be ? ToObject(this value).
|
||||||
|
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Array.prototype.at.call(undefined);
|
||||||
|
}, '`Array.prototype.at.call(undefined)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
Array.prototype.at.call(null);
|
||||||
|
}, '`Array.prototype.at.call(null)` throws TypeError');
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-array.prototype.item
|
esid: sec-array.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Returns the item value at the specified relative index
|
Returns the item value at the specified relative index
|
||||||
info: |
|
info: |
|
||||||
@ -17,14 +17,14 @@ info: |
|
|||||||
If k < 0 or k ≥ len, then return undefined.
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
features: [Array.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
let a = [1, 2, 3, 4, ,5];
|
let a = [1, 2, 3, 4, ,5];
|
||||||
|
|
||||||
assert.sameValue(a.item(0), 1, 'a.item(0) must return 1');
|
assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
|
||||||
assert.sameValue(a.item(-1), 5, 'a.item(-1) must return 5');
|
assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5');
|
||||||
assert.sameValue(a.item(-2), undefined, 'a.item(-2) must return undefined');
|
assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined');
|
||||||
assert.sameValue(a.item(-3), 4, 'a.item(-3) must return 4');
|
assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4');
|
||||||
assert.sameValue(a.item(-4), 3, 'a.item(-4) must return 3');
|
assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3');
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-array.prototype.item
|
esid: sec-array.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Returns the item value at the specified index
|
Returns the item value at the specified index
|
||||||
info: |
|
info: |
|
||||||
@ -17,15 +17,15 @@ info: |
|
|||||||
If k < 0 or k ≥ len, then return undefined.
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
features: [Array.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
let a = [1, 2, 3, 4,,5];
|
let a = [1, 2, 3, 4,,5];
|
||||||
|
|
||||||
assert.sameValue(a.item(0), 1, 'a.item(0) must return 1');
|
assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
|
||||||
assert.sameValue(a.item(1), 2, 'a.item(1) must return 2');
|
assert.sameValue(a.at(1), 2, 'a.at(1) must return 2');
|
||||||
assert.sameValue(a.item(2), 3, 'a.item(2) must return 3');
|
assert.sameValue(a.at(2), 3, 'a.at(2) must return 3');
|
||||||
assert.sameValue(a.item(3), 4, 'a.item(3) must return 4');
|
assert.sameValue(a.at(3), 4, 'a.at(3) must return 4');
|
||||||
assert.sameValue(a.item(4), undefined, 'a.item(4) must return undefined');
|
assert.sameValue(a.at(4), undefined, 'a.at(4) must return undefined');
|
||||||
assert.sameValue(a.item(5), 5, 'a.item(5) must return 5');
|
assert.sameValue(a.at(5), 5, 'a.at(5) must return 5');
|
43
test/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
vendored
Normal file
43
test/built-ins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Returns the item value at the specified index, respecting holes in sparse arrays.
|
||||||
|
info: |
|
||||||
|
Array.prototypeitem ( )
|
||||||
|
|
||||||
|
Let O be ? ToObject(this value).
|
||||||
|
Let len be ? LengthOfArrayLike(O).
|
||||||
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
If relativeIndex ≥ 0, then
|
||||||
|
Let k be relativeIndex.
|
||||||
|
Else,
|
||||||
|
Let k be len + relativeIndex.
|
||||||
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof Array.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof Array.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
let a = [0, 1, , 3, 4, , 6];
|
||||||
|
|
||||||
|
assert.sameValue(a.at(0), 0, 'a.at(0) must return 0');
|
||||||
|
assert.sameValue(a.at(1), 1, 'a.at(1) must return 1');
|
||||||
|
assert.sameValue(a.at(2), undefined, 'a.at(2) must return undefined');
|
||||||
|
assert.sameValue(a.at(3), 3, 'a.at(3) must return 3');
|
||||||
|
assert.sameValue(a.at(4), 4, 'a.at(4) must return 4');
|
||||||
|
assert.sameValue(a.at(5), undefined, 'a.at(5) must return undefined');
|
||||||
|
assert.sameValue(a.at(6), 6, 'a.at(6) must return 6');
|
||||||
|
assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0');
|
||||||
|
assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6');
|
||||||
|
assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined');
|
||||||
|
assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4');
|
||||||
|
assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3');
|
||||||
|
assert.sameValue(a.at(-5), undefined, 'a.at(-5) must return undefined');
|
||||||
|
assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1');
|
20
test/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
20
test/built-ins/Array/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.at
|
||||||
|
description: >
|
||||||
|
Returns undefined if the specified index less than or greater than the available index range.
|
||||||
|
info: |
|
||||||
|
Array.prototype.at( index )
|
||||||
|
|
||||||
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
|
features: [Array.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof Array.prototype.at, 'function');
|
||||||
|
|
||||||
|
let a = [];
|
||||||
|
|
||||||
|
assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined'); // wrap around the end
|
||||||
|
assert.sameValue(a.at(0), undefined, 'a.at(0) must return undefined');
|
||||||
|
assert.sameValue(a.at(1), undefined, 'a.at(1) must return undefined');
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Property type and descriptor.
|
|
||||||
info: |
|
|
||||||
Array.prototype.item( index )
|
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
|
||||||
|
|
||||||
let a = [0,1,2,3];
|
|
||||||
|
|
||||||
assert.sameValue(a.item(false), 0, 'a.item(false) must return 0');
|
|
||||||
assert.sameValue(a.item(null), 0, 'a.item(null) must return 0');
|
|
||||||
assert.sameValue(a.item(undefined), 0, 'a.item(undefined) must return 0');
|
|
||||||
assert.sameValue(a.item(""), 0, 'a.item("") must return 0');
|
|
||||||
assert.sameValue(a.item(function() {}), 0, 'a.item(function() {}) must return 0');
|
|
||||||
assert.sameValue(a.item([]), 0, 'a.item([]) must return 0');
|
|
||||||
|
|
||||||
assert.sameValue(a.item(true), 1, 'a.item(true) must return 1');
|
|
||||||
assert.sameValue(a.item("1"), 1, 'a.item("1") must return 1');
|
|
24
test/built-ins/Array/prototype/item/length.js
vendored
24
test/built-ins/Array/prototype/item/length.js
vendored
@ -1,24 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Array.prototype.item.length value and descriptor.
|
|
||||||
info: |
|
|
||||||
Array.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
Array.prototype.item.length, 1,
|
|
||||||
'The value of Array.prototype.item.length is 1'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(Array.prototype.item, 'length');
|
|
||||||
verifyNotWritable(Array.prototype.item, 'length');
|
|
||||||
verifyConfigurable(Array.prototype.item, 'length');
|
|
24
test/built-ins/Array/prototype/item/name.js
vendored
24
test/built-ins/Array/prototype/item/name.js
vendored
@ -1,24 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Array.prototype.item.name value and descriptor.
|
|
||||||
info: |
|
|
||||||
Array.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
Array.prototype.item.name, 'item',
|
|
||||||
'The value of Array.prototype.item.name is "item"'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(Array.prototype.item, 'name');
|
|
||||||
verifyNotWritable(Array.prototype.item, 'name');
|
|
||||||
verifyConfigurable(Array.prototype.item, 'name');
|
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Return abrupt from ToObject(this value).
|
|
||||||
info: |
|
|
||||||
Array.prototype.item( index )
|
|
||||||
|
|
||||||
Let O be ? ToObject(this value).
|
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
Array.prototype.item.call(undefined);
|
|
||||||
}, '`Array.prototype.item.call(undefined)` throws TypeError');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
Array.prototype.item.call(null);
|
|
||||||
}, '`Array.prototype.item.call(null)` throws TypeError');
|
|
@ -1,43 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Returns the item value at the specified index, respecting holes in sparse arrays.
|
|
||||||
info: |
|
|
||||||
Array.prototypeitem ( )
|
|
||||||
|
|
||||||
Let O be ? ToObject(this value).
|
|
||||||
Let len be ? LengthOfArrayLike(O).
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
|
||||||
If relativeIndex ≥ 0, then
|
|
||||||
Let k be relativeIndex.
|
|
||||||
Else,
|
|
||||||
Let k be len + relativeIndex.
|
|
||||||
If k < 0 or k ≥ len, then return undefined.
|
|
||||||
Return ? Get(O, ! ToString(k)).
|
|
||||||
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof Array.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof Array.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
let a = [0, 1, , 3, 4, , 6];
|
|
||||||
|
|
||||||
assert.sameValue(a.item(0), 0, 'a.item(0) must return 0');
|
|
||||||
assert.sameValue(a.item(1), 1, 'a.item(1) must return 1');
|
|
||||||
assert.sameValue(a.item(2), undefined, 'a.item(2) must return undefined');
|
|
||||||
assert.sameValue(a.item(3), 3, 'a.item(3) must return 3');
|
|
||||||
assert.sameValue(a.item(4), 4, 'a.item(4) must return 4');
|
|
||||||
assert.sameValue(a.item(5), undefined, 'a.item(5) must return undefined');
|
|
||||||
assert.sameValue(a.item(6), 6, 'a.item(6) must return 6');
|
|
||||||
assert.sameValue(a.item(-0), 0, 'a.item(-0) must return 0');
|
|
||||||
assert.sameValue(a.item(-1), 6, 'a.item(-1) must return 6');
|
|
||||||
assert.sameValue(a.item(-2), undefined, 'a.item(-2) must return undefined');
|
|
||||||
assert.sameValue(a.item(-3), 4, 'a.item(-3) must return 4');
|
|
||||||
assert.sameValue(a.item(-4), 3, 'a.item(-4) must return 3');
|
|
||||||
assert.sameValue(a.item(-5), undefined, 'a.item(-5) must return undefined');
|
|
||||||
assert.sameValue(a.item(-6), 1, 'a.item(-6) must return 1');
|
|
@ -1,20 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-array.prototype.item
|
|
||||||
description: >
|
|
||||||
Returns undefined if the specified index less than or greater than the available index range.
|
|
||||||
info: |
|
|
||||||
Array.prototype.item( index )
|
|
||||||
|
|
||||||
If k < 0 or k ≥ len, then return undefined.
|
|
||||||
features: [Array.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof Array.prototype.item, 'function');
|
|
||||||
|
|
||||||
let a = [];
|
|
||||||
|
|
||||||
assert.sameValue(a.item(-2), undefined, 'a.item(-2) must return undefined'); // wrap around the end
|
|
||||||
assert.sameValue(a.item(0), undefined, 'a.item(0) must return undefined');
|
|
||||||
assert.sameValue(a.item(1), undefined, 'a.item(1) must return undefined');
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-string.prototype.item
|
esid: sec-string.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
String.prototype.item( index )
|
String.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
let valueOfCallCount = 0;
|
let valueOfCallCount = 0;
|
||||||
let index = {
|
let index = {
|
||||||
@ -23,5 +23,5 @@ let index = {
|
|||||||
|
|
||||||
let s = "01";
|
let s = "01";
|
||||||
|
|
||||||
assert.sameValue(s.item(index), '1', 's.item({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
assert.sameValue(s.at(index), '1', 's.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
||||||
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
@ -1,20 +1,20 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-string.prototype.item
|
esid: sec-string.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
String.prototype.item( index )
|
String.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
let s = "01";
|
let s = "01";
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
s.item(Symbol());
|
s.at(Symbol());
|
||||||
}, '`s.item(Symbol())` throws TypeError');
|
}, '`s.at(Symbol())` throws TypeError');
|
26
test/built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
26
test/built-ins/String/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-string.prototype.at
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: |
|
||||||
|
String.prototype.at( index )
|
||||||
|
|
||||||
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
|
features: [String.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
|
let s = "01";
|
||||||
|
|
||||||
|
assert.sameValue(s.at(false), '0', 's.at(false) must return 0');
|
||||||
|
assert.sameValue(s.at(null), '0', 's.at(null) must return 0');
|
||||||
|
assert.sameValue(s.at(undefined), '0', 's.at(undefined) must return 0');
|
||||||
|
assert.sameValue(s.at(""), '0', 's.at("") must return 0');
|
||||||
|
assert.sameValue(s.at(function() {}), '0', 's.at(function() {}) must return 0');
|
||||||
|
assert.sameValue(s.at([]), '0', 's.at([]) must return 0');
|
||||||
|
|
||||||
|
assert.sameValue(s.at(true), '1', 's.at(true) must return 1');
|
||||||
|
assert.sameValue(s.at("1"), '1', 's.at("1") must return 1');
|
24
test/built-ins/String/prototype/at/length.js
vendored
Normal file
24
test/built-ins/String/prototype/at/length.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-string.prototype.at
|
||||||
|
description: >
|
||||||
|
String.prototype.at.length value and descriptor.
|
||||||
|
info: |
|
||||||
|
String.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [String.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
String.prototype.at.length, 1,
|
||||||
|
'The value of String.prototype.at.length is 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(String.prototype.at, 'length');
|
||||||
|
verifyNotWritable(String.prototype.at, 'length');
|
||||||
|
verifyConfigurable(String.prototype.at, 'length');
|
24
test/built-ins/String/prototype/at/name.js
vendored
Normal file
24
test/built-ins/String/prototype/at/name.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-string.prototype.at
|
||||||
|
description: >
|
||||||
|
String.prototype.at.name value and descriptor.
|
||||||
|
info: |
|
||||||
|
String.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
features: [String.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
String.prototype.at.name, 'item',
|
||||||
|
'The value of String.prototype.at.name is "item"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(String.prototype.at, 'name');
|
||||||
|
verifyNotWritable(String.prototype.at, 'name');
|
||||||
|
verifyConfigurable(String.prototype.at, 'name');
|
@ -1,22 +1,22 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-string.prototype.item
|
esid: sec-string.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
String.prototype.item( index )
|
String.prototype.at( index )
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js]
|
includes: [propertyHelper.js]
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof String.prototype.item,
|
typeof String.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof String.prototype.item` is "function"'
|
'The value of `typeof String.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
verifyNotEnumerable(String.prototype, 'item');
|
verifyNotEnumerable(String.prototype, 'item');
|
22
test/built-ins/String/prototype/at/return-abrupt-from-this.js
vendored
Normal file
22
test/built-ins/String/prototype/at/return-abrupt-from-this.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-string.prototype.at
|
||||||
|
description: >
|
||||||
|
Return abrupt from RequireObjectCoercible(this value).
|
||||||
|
info: |
|
||||||
|
String.prototype.at( index )
|
||||||
|
|
||||||
|
Let O be ? RequireObjectCoercible(this value).
|
||||||
|
|
||||||
|
features: [String.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
String.prototype.at.call(undefined);
|
||||||
|
}, '`String.prototype.at.call(undefined)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
String.prototype.at.call(null);
|
||||||
|
}, '`String.prototype.at.call(null)` throws TypeError');
|
@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-String.prototype.item
|
esid: sec-String.prototype.at
|
||||||
description: >
|
description: >
|
||||||
The method should return an Iterator instance.
|
The method should return an Iterator instance.
|
||||||
info: |
|
info: |
|
||||||
@ -17,14 +17,14 @@ info: |
|
|||||||
If k < 0 or k ≥ len, then return undefined.
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
let s = "12\uD80034";
|
let s = "12\uD80034";
|
||||||
|
|
||||||
assert.sameValue(s.item(0), "1", 's.item(0) must return "1"');
|
assert.sameValue(s.at(0), "1", 's.at(0) must return "1"');
|
||||||
assert.sameValue(s.item(1), "2", 's.item(1) must return "2"');
|
assert.sameValue(s.at(1), "2", 's.at(1) must return "2"');
|
||||||
assert.sameValue(s.item(2), "\uD800", 's.item(2) must return "\\uD800"');
|
assert.sameValue(s.at(2), "\uD800", 's.at(2) must return "\\uD800"');
|
||||||
assert.sameValue(s.item(3), "3", 's.item(3) must return "3"');
|
assert.sameValue(s.at(3), "3", 's.at(3) must return "3"');
|
||||||
assert.sameValue(s.item(4), "4", 's.item(4) must return "4"');
|
assert.sameValue(s.at(4), "4", 's.at(4) must return "4"');
|
@ -17,13 +17,13 @@ info: |
|
|||||||
If k < 0 or k ≥ len, then return undefined.
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
let s = "12345";
|
let s = "12345";
|
||||||
|
|
||||||
assert.sameValue(s.item(0), "1", 's.item(0) must return "1"');
|
assert.sameValue(s.at(0), "1", 's.at(0) must return "1"');
|
||||||
assert.sameValue(s.item(-1), "5", 's.item(-1) must return "5"');
|
assert.sameValue(s.at(-1), "5", 's.at(-1) must return "5"');
|
||||||
assert.sameValue(s.item(-3), "3", 's.item(-3) must return "3"');
|
assert.sameValue(s.at(-3), "3", 's.at(-3) must return "3"');
|
||||||
assert.sameValue(s.item(-4), "2", 's.item(-4) must return "2"');
|
assert.sameValue(s.at(-4), "2", 's.at(-4) must return "2"');
|
@ -17,14 +17,14 @@ info: |
|
|||||||
If k < 0 or k ≥ len, then return undefined.
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
features: [String.prototype.item]
|
features: [String.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
let s = "12345";
|
let s = "12345";
|
||||||
|
|
||||||
assert.sameValue(s.item(0), "1", 's.item(0) must return "1"');
|
assert.sameValue(s.at(0), "1", 's.at(0) must return "1"');
|
||||||
assert.sameValue(s.item(1), "2", 's.item(1) must return "2"');
|
assert.sameValue(s.at(1), "2", 's.at(1) must return "2"');
|
||||||
assert.sameValue(s.item(2), "3", 's.item(2) must return "3"');
|
assert.sameValue(s.at(2), "3", 's.at(2) must return "3"');
|
||||||
assert.sameValue(s.item(3), "4", 's.item(3) must return "4"');
|
assert.sameValue(s.at(3), "4", 's.at(3) must return "4"');
|
||||||
assert.sameValue(s.item(4), "5", 's.item(4) must return "5"');
|
assert.sameValue(s.at(4), "5", 's.at(4) must return "5"');
|
20
test/built-ins/String/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
20
test/built-ins/String/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-string.prototype.at
|
||||||
|
description: >
|
||||||
|
Creates an iterator from a custom object.
|
||||||
|
info: |
|
||||||
|
String.prototype.at( index )
|
||||||
|
|
||||||
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
|
features: [String.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(typeof String.prototype.at, 'function');
|
||||||
|
|
||||||
|
let s = "";
|
||||||
|
|
||||||
|
assert.sameValue(s.at(-2), undefined, 's.at(-2) must return undefined'); // wrap around the end
|
||||||
|
assert.sameValue(s.at(0), undefined, 's.at(0) must return undefined');
|
||||||
|
assert.sameValue(s.at(1), undefined, 's.at(1) must return undefined');
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-string.prototype.item
|
|
||||||
description: >
|
|
||||||
Property type and descriptor.
|
|
||||||
info: |
|
|
||||||
String.prototype.item( index )
|
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
|
||||||
|
|
||||||
features: [String.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
|
||||||
|
|
||||||
let s = "01";
|
|
||||||
|
|
||||||
assert.sameValue(s.item(false), '0', 's.item(false) must return 0');
|
|
||||||
assert.sameValue(s.item(null), '0', 's.item(null) must return 0');
|
|
||||||
assert.sameValue(s.item(undefined), '0', 's.item(undefined) must return 0');
|
|
||||||
assert.sameValue(s.item(""), '0', 's.item("") must return 0');
|
|
||||||
assert.sameValue(s.item(function() {}), '0', 's.item(function() {}) must return 0');
|
|
||||||
assert.sameValue(s.item([]), '0', 's.item([]) must return 0');
|
|
||||||
|
|
||||||
assert.sameValue(s.item(true), '1', 's.item(true) must return 1');
|
|
||||||
assert.sameValue(s.item("1"), '1', 's.item("1") must return 1');
|
|
24
test/built-ins/String/prototype/item/length.js
vendored
24
test/built-ins/String/prototype/item/length.js
vendored
@ -1,24 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-string.prototype.item
|
|
||||||
description: >
|
|
||||||
String.prototype.item.length value and descriptor.
|
|
||||||
info: |
|
|
||||||
String.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [String.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
String.prototype.item.length, 1,
|
|
||||||
'The value of String.prototype.item.length is 1'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(String.prototype.item, 'length');
|
|
||||||
verifyNotWritable(String.prototype.item, 'length');
|
|
||||||
verifyConfigurable(String.prototype.item, 'length');
|
|
24
test/built-ins/String/prototype/item/name.js
vendored
24
test/built-ins/String/prototype/item/name.js
vendored
@ -1,24 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-string.prototype.item
|
|
||||||
description: >
|
|
||||||
String.prototype.item.name value and descriptor.
|
|
||||||
info: |
|
|
||||||
String.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js]
|
|
||||||
features: [String.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
String.prototype.item.name, 'item',
|
|
||||||
'The value of String.prototype.item.name is "item"'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(String.prototype.item, 'name');
|
|
||||||
verifyNotWritable(String.prototype.item, 'name');
|
|
||||||
verifyConfigurable(String.prototype.item, 'name');
|
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-string.prototype.item
|
|
||||||
description: >
|
|
||||||
Return abrupt from RequireObjectCoercible(this value).
|
|
||||||
info: |
|
|
||||||
String.prototype.item( index )
|
|
||||||
|
|
||||||
Let O be ? RequireObjectCoercible(this value).
|
|
||||||
|
|
||||||
features: [String.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
String.prototype.item.call(undefined);
|
|
||||||
}, '`String.prototype.item.call(undefined)` throws TypeError');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
String.prototype.item.call(null);
|
|
||||||
}, '`String.prototype.item.call(null)` throws TypeError');
|
|
@ -1,20 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-string.prototype.item
|
|
||||||
description: >
|
|
||||||
Creates an iterator from a custom object.
|
|
||||||
info: |
|
|
||||||
String.prototype.item( index )
|
|
||||||
|
|
||||||
If k < 0 or k ≥ len, then return undefined.
|
|
||||||
features: [String.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(typeof String.prototype.item, 'function');
|
|
||||||
|
|
||||||
let s = "";
|
|
||||||
|
|
||||||
assert.sameValue(s.item(-2), undefined, 's.item(-2) must return undefined'); // wrap around the end
|
|
||||||
assert.sameValue(s.item(0), undefined, 's.item(0) must return undefined');
|
|
||||||
assert.sameValue(s.item(1), undefined, 's.item(1) must return undefined');
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-%typedarray%.prototype.item
|
esid: sec-%typedarray%.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
%TypedArray%.prototype.item( index )
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
includes: [testTypedArray.js]
|
||||||
features: [TypedArray, TypedArray.prototype.item]
|
features: [TypedArray, TypedArray.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof TypedArray.prototype.item,
|
typeof TypedArray.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
testWithTypedArrayConstructors(TA => {
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
let valueOfCallCount = 0;
|
let valueOfCallCount = 0;
|
||||||
let index = {
|
let index = {
|
||||||
valueOf() {
|
valueOf() {
|
||||||
@ -30,6 +30,6 @@ testWithTypedArrayConstructors(TA => {
|
|||||||
|
|
||||||
let a = new TA([0,1,2,3]);
|
let a = new TA([0,1,2,3]);
|
||||||
|
|
||||||
assert.sameValue(a.item(index), 1, 'a.item({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1');
|
||||||
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1');
|
||||||
});
|
});
|
@ -1,28 +1,28 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-%typedarray%.prototype.item
|
esid: sec-%typedarray%.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
%TypedArray%.prototype.item( index )
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
includes: [testTypedArray.js]
|
||||||
features: [TypedArray, TypedArray.prototype.item]
|
features: [TypedArray, TypedArray.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof TypedArray.prototype.item,
|
typeof TypedArray.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
testWithTypedArrayConstructors(TA => {
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
let a = new TA([0,1,2,3]);
|
let a = new TA([0,1,2,3]);
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
assert.throws(TypeError, () => {
|
||||||
a.item(Symbol());
|
a.at(Symbol());
|
||||||
}, '`a.item(Symbol())` throws TypeError');
|
}, '`a.at(Symbol())` throws TypeError');
|
||||||
});
|
});
|
35
test/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
35
test/built-ins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
Property type and descriptor.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
features: [TypedArray, TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(TA => {
|
||||||
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
|
|
||||||
|
let a = new TA([0,1,2,3]);
|
||||||
|
|
||||||
|
assert.sameValue(a.at(false), 0, 'a.at(false) must return 0');
|
||||||
|
assert.sameValue(a.at(null), 0, 'a.at(null) must return 0');
|
||||||
|
assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0');
|
||||||
|
assert.sameValue(a.at(""), 0, 'a.at("") must return 0');
|
||||||
|
assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0');
|
||||||
|
assert.sameValue(a.at([]), 0, 'a.at([]) must return 0');
|
||||||
|
|
||||||
|
assert.sameValue(a.at(true), 1, 'a.at(true) must return 1');
|
||||||
|
assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1');
|
||||||
|
});
|
28
test/built-ins/TypedArray/prototype/at/length.js
vendored
Normal file
28
test/built-ins/TypedArray/prototype/at/length.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
TypedArray.prototype.at.length value and descriptor.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js, testTypedArray.js]
|
||||||
|
features: [TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
TypedArray.prototype.at.length, 1,
|
||||||
|
'The value of TypedArray.prototype.at.length is 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(TypedArray.prototype.at, 'length');
|
||||||
|
verifyNotWritable(TypedArray.prototype.at, 'length');
|
||||||
|
verifyConfigurable(TypedArray.prototype.at, 'length');
|
28
test/built-ins/TypedArray/prototype/at/name.js
vendored
Normal file
28
test/built-ins/TypedArray/prototype/at/name.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
%TypedArray%.prototype.at.name value and descriptor.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
|
||||||
|
includes: [propertyHelper.js, testTypedArray.js]
|
||||||
|
features: [TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.sameValue(
|
||||||
|
TypedArray.prototype.at.name, 'item',
|
||||||
|
'The value of TypedArray.prototype.at.name is "item"'
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyNotEnumerable(TypedArray.prototype.at, 'name');
|
||||||
|
verifyNotWritable(TypedArray.prototype.at, 'name');
|
||||||
|
verifyConfigurable(TypedArray.prototype.at, 'name');
|
@ -1,20 +1,20 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-%typedarray%.prototype.item
|
esid: sec-%typedarray%.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Property type and descriptor.
|
Property type and descriptor.
|
||||||
info: |
|
info: |
|
||||||
%TypedArray%.prototype.item( index )
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
17 ECMAScript Standard Built-in Objects
|
||||||
includes: [propertyHelper.js, testTypedArray.js]
|
includes: [propertyHelper.js, testTypedArray.js]
|
||||||
features: [TypedArray.prototype.item]
|
features: [TypedArray.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof TypedArray.prototype.item,
|
typeof TypedArray.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
verifyNotEnumerable(TypedArray.prototype, 'item');
|
verifyNotEnumerable(TypedArray.prototype, 'item');
|
40
test/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js
vendored
Normal file
40
test/built-ins/TypedArray/prototype/at/return-abrupt-from-this.js
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
Return abrupt from ToObject(this value).
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
Let O be the this value.
|
||||||
|
Perform ? ValidateTypedArray(O).
|
||||||
|
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
features: [TypedArray,TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
TypedArray.prototype.at.call(undefined);
|
||||||
|
}, '`TypedArray.prototype.at.call(undefined)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
TypedArray.prototype.at.call(null);
|
||||||
|
}, '`TypedArray.prototype.at.call(null)` throws TypeError');
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(TA => {
|
||||||
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
TA.prototype.at.call(undefined);
|
||||||
|
}, '`TA.prototype.at.call(undefined)` throws TypeError');
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => {
|
||||||
|
TA.prototype.at.call(null);
|
||||||
|
}, '`TA.prototype.at.call(null)` throws TypeError');
|
||||||
|
});
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-%typedarray%.prototype.item
|
esid: sec-%typedarray%.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Returns the item value at the specified relative index
|
Returns the item value at the specified relative index
|
||||||
info: |
|
info: |
|
||||||
%TypedArray%.prototype.item( index )
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
Let O be the this value.
|
Let O be the this value.
|
||||||
Perform ? ValidateTypedArray(O).
|
Perform ? ValidateTypedArray(O).
|
||||||
@ -19,19 +19,19 @@ info: |
|
|||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
includes: [testTypedArray.js]
|
||||||
features: [TypedArray,TypedArray.prototype.item]
|
features: [TypedArray,TypedArray.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof TypedArray.prototype.item,
|
typeof TypedArray.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
testWithTypedArrayConstructors(TA => {
|
||||||
let a = new TA([1, 2, 3, 4, 5]);
|
let a = new TA([1, 2, 3, 4, 5]);
|
||||||
assert.sameValue(a.item(0), 1, 'a.item(0) must return 1');
|
assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
|
||||||
assert.sameValue(a.item(-1), 5, 'a.item(-1) must return 5');
|
assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5');
|
||||||
assert.sameValue(a.item(-2), 4, 'a.item(-2) must return 4');
|
assert.sameValue(a.at(-2), 4, 'a.at(-2) must return 4');
|
||||||
assert.sameValue(a.item(-3), 3, 'a.item(-3) must return 3');
|
assert.sameValue(a.at(-3), 3, 'a.at(-3) must return 3');
|
||||||
assert.sameValue(a.item(-4), 2, 'a.item(-4) must return 2');
|
assert.sameValue(a.at(-4), 2, 'a.at(-4) must return 2');
|
||||||
});
|
});
|
@ -1,11 +1,11 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
esid: sec-%typedarray%.prototype.item
|
esid: sec-%typedarray%.prototype.at
|
||||||
description: >
|
description: >
|
||||||
Returns the item value at the specified index
|
Returns the item value at the specified index
|
||||||
info: |
|
info: |
|
||||||
%TypedArray%.prototype.item( index )
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
Let O be the this value.
|
Let O be the this value.
|
||||||
Perform ? ValidateTypedArray(O).
|
Perform ? ValidateTypedArray(O).
|
||||||
@ -19,20 +19,20 @@ info: |
|
|||||||
Return ? Get(O, ! ToString(k)).
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
includes: [testTypedArray.js]
|
||||||
features: [TypedArray,TypedArray.prototype.item]
|
features: [TypedArray,TypedArray.prototype.at]
|
||||||
---*/
|
---*/
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
typeof TypedArray.prototype.item,
|
typeof TypedArray.prototype.at,
|
||||||
'function',
|
'function',
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
);
|
);
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
testWithTypedArrayConstructors(TA => {
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
let a = new TA([1, 2, 3, 4]);
|
let a = new TA([1, 2, 3, 4]);
|
||||||
|
|
||||||
assert.sameValue(a.item(0), 1, 'a.item(0) must return 1');
|
assert.sameValue(a.at(0), 1, 'a.at(0) must return 1');
|
||||||
assert.sameValue(a.item(1), 2, 'a.item(1) must return 2');
|
assert.sameValue(a.at(1), 2, 'a.at(1) must return 2');
|
||||||
assert.sameValue(a.item(2), 3, 'a.item(2) must return 3');
|
assert.sameValue(a.at(2), 3, 'a.at(2) must return 3');
|
||||||
assert.sameValue(a.item(3), 4, 'a.item(3) must return 4');
|
assert.sameValue(a.at(3), 4, 'a.at(3) must return 4');
|
||||||
});
|
});
|
50
test/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
Returns the item value at the specified index, holes are filled in sparse arrays.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
Let O be the this value.
|
||||||
|
Perform ? ValidateTypedArray(O).
|
||||||
|
Let len be O.[[ArrayLength]].
|
||||||
|
Let relativeIndex be ? ToInteger(index).
|
||||||
|
If relativeIndex ≥ 0, then
|
||||||
|
Let k be relativeIndex.
|
||||||
|
Else,
|
||||||
|
Let k be len + relativeIndex.
|
||||||
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
|
Return ? Get(O, ! ToString(k)).
|
||||||
|
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
features: [TypedArray, TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(TA => {
|
||||||
|
let a = new TA([0, 1, , 3, 4, , 6]);
|
||||||
|
let filler = 0;
|
||||||
|
if (TA.name.startsWith('Float')) {
|
||||||
|
filler = NaN;
|
||||||
|
}
|
||||||
|
assert.sameValue(a.at(0), 0, 'a.at(0) must return 0');
|
||||||
|
assert.sameValue(a.at(1), 1, 'a.at(1) must return 1');
|
||||||
|
assert.sameValue(a.at(2), filler, 'a.at(2) must return the value of filler');
|
||||||
|
assert.sameValue(a.at(3), 3, 'a.at(3) must return 3');
|
||||||
|
assert.sameValue(a.at(4), 4, 'a.at(4) must return 4');
|
||||||
|
assert.sameValue(a.at(5), filler, 'a.at(5) must return the value of filler');
|
||||||
|
assert.sameValue(a.at(6), 6, 'a.at(6) must return 6');
|
||||||
|
assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0');
|
||||||
|
assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6');
|
||||||
|
assert.sameValue(a.at(-2), filler, 'a.at(-2) must return the value of filler');
|
||||||
|
assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4');
|
||||||
|
assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3');
|
||||||
|
assert.sameValue(a.at(-5), filler, 'a.at(-5) must return the value of filler');
|
||||||
|
assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1');
|
||||||
|
});
|
28
test/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
28
test/built-ins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.at
|
||||||
|
description: >
|
||||||
|
Returns undefined if the specified index less than or greater than the available index range.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.at( index )
|
||||||
|
|
||||||
|
If k < 0 or k ≥ len, then return undefined.
|
||||||
|
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
features: [TypedArray,TypedArray.prototype.at]
|
||||||
|
---*/
|
||||||
|
assert.sameValue(
|
||||||
|
typeof TypedArray.prototype.at,
|
||||||
|
'function',
|
||||||
|
'The value of `typeof TypedArray.prototype.at` is "function"'
|
||||||
|
);
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(TA => {
|
||||||
|
assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"');
|
||||||
|
let a = new TA([]);
|
||||||
|
|
||||||
|
assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined'); // wrap around the end
|
||||||
|
assert.sameValue(a.at(0), undefined, 'a.at(0) must return undefined');
|
||||||
|
assert.sameValue(a.at(1), undefined, 'a.at(1) must return undefined');
|
||||||
|
});
|
@ -1,35 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
Property type and descriptor.
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
|
||||||
features: [TypedArray, TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
|
||||||
|
|
||||||
let a = new TA([0,1,2,3]);
|
|
||||||
|
|
||||||
assert.sameValue(a.item(false), 0, 'a.item(false) must return 0');
|
|
||||||
assert.sameValue(a.item(null), 0, 'a.item(null) must return 0');
|
|
||||||
assert.sameValue(a.item(undefined), 0, 'a.item(undefined) must return 0');
|
|
||||||
assert.sameValue(a.item(""), 0, 'a.item("") must return 0');
|
|
||||||
assert.sameValue(a.item(function() {}), 0, 'a.item(function() {}) must return 0');
|
|
||||||
assert.sameValue(a.item([]), 0, 'a.item([]) must return 0');
|
|
||||||
|
|
||||||
assert.sameValue(a.item(true), 1, 'a.item(true) must return 1');
|
|
||||||
assert.sameValue(a.item("1"), 1, 'a.item("1") must return 1');
|
|
||||||
});
|
|
@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
TypedArray.prototype.item.length value and descriptor.
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js, testTypedArray.js]
|
|
||||||
features: [TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
TypedArray.prototype.item.length, 1,
|
|
||||||
'The value of TypedArray.prototype.item.length is 1'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(TypedArray.prototype.item, 'length');
|
|
||||||
verifyNotWritable(TypedArray.prototype.item, 'length');
|
|
||||||
verifyConfigurable(TypedArray.prototype.item, 'length');
|
|
28
test/built-ins/TypedArray/prototype/item/name.js
vendored
28
test/built-ins/TypedArray/prototype/item/name.js
vendored
@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
%TypedArray%.prototype.item.name value and descriptor.
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
17 ECMAScript Standard Built-in Objects
|
|
||||||
|
|
||||||
includes: [propertyHelper.js, testTypedArray.js]
|
|
||||||
features: [TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
TypedArray.prototype.item.name, 'item',
|
|
||||||
'The value of TypedArray.prototype.item.name is "item"'
|
|
||||||
);
|
|
||||||
|
|
||||||
verifyNotEnumerable(TypedArray.prototype.item, 'name');
|
|
||||||
verifyNotWritable(TypedArray.prototype.item, 'name');
|
|
||||||
verifyConfigurable(TypedArray.prototype.item, 'name');
|
|
@ -1,40 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
Return abrupt from ToObject(this value).
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
Let O be the this value.
|
|
||||||
Perform ? ValidateTypedArray(O).
|
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
|
||||||
features: [TypedArray,TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
TypedArray.prototype.item.call(undefined);
|
|
||||||
}, '`TypedArray.prototype.item.call(undefined)` throws TypeError');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
TypedArray.prototype.item.call(null);
|
|
||||||
}, '`TypedArray.prototype.item.call(null)` throws TypeError');
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
TA.prototype.item.call(undefined);
|
|
||||||
}, '`TA.prototype.item.call(undefined)` throws TypeError');
|
|
||||||
|
|
||||||
assert.throws(TypeError, () => {
|
|
||||||
TA.prototype.item.call(null);
|
|
||||||
}, '`TA.prototype.item.call(null)` throws TypeError');
|
|
||||||
});
|
|
@ -1,50 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
Returns the item value at the specified index, holes are filled in sparse arrays.
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
Let O be the this value.
|
|
||||||
Perform ? ValidateTypedArray(O).
|
|
||||||
Let len be O.[[ArrayLength]].
|
|
||||||
Let relativeIndex be ? ToInteger(index).
|
|
||||||
If relativeIndex ≥ 0, then
|
|
||||||
Let k be relativeIndex.
|
|
||||||
Else,
|
|
||||||
Let k be len + relativeIndex.
|
|
||||||
If k < 0 or k ≥ len, then return undefined.
|
|
||||||
Return ? Get(O, ! ToString(k)).
|
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
|
||||||
features: [TypedArray, TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
|
||||||
let a = new TA([0, 1, , 3, 4, , 6]);
|
|
||||||
let filler = 0;
|
|
||||||
if (TA.name.startsWith('Float')) {
|
|
||||||
filler = NaN;
|
|
||||||
}
|
|
||||||
assert.sameValue(a.item(0), 0, 'a.item(0) must return 0');
|
|
||||||
assert.sameValue(a.item(1), 1, 'a.item(1) must return 1');
|
|
||||||
assert.sameValue(a.item(2), filler, 'a.item(2) must return the value of filler');
|
|
||||||
assert.sameValue(a.item(3), 3, 'a.item(3) must return 3');
|
|
||||||
assert.sameValue(a.item(4), 4, 'a.item(4) must return 4');
|
|
||||||
assert.sameValue(a.item(5), filler, 'a.item(5) must return the value of filler');
|
|
||||||
assert.sameValue(a.item(6), 6, 'a.item(6) must return 6');
|
|
||||||
assert.sameValue(a.item(-0), 0, 'a.item(-0) must return 0');
|
|
||||||
assert.sameValue(a.item(-1), 6, 'a.item(-1) must return 6');
|
|
||||||
assert.sameValue(a.item(-2), filler, 'a.item(-2) must return the value of filler');
|
|
||||||
assert.sameValue(a.item(-3), 4, 'a.item(-3) must return 4');
|
|
||||||
assert.sameValue(a.item(-4), 3, 'a.item(-4) must return 3');
|
|
||||||
assert.sameValue(a.item(-5), filler, 'a.item(-5) must return the value of filler');
|
|
||||||
assert.sameValue(a.item(-6), 1, 'a.item(-6) must return 1');
|
|
||||||
});
|
|
@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
esid: sec-%typedarray%.prototype.item
|
|
||||||
description: >
|
|
||||||
Returns undefined if the specified index less than or greater than the available index range.
|
|
||||||
info: |
|
|
||||||
%TypedArray%.prototype.item( index )
|
|
||||||
|
|
||||||
If k < 0 or k ≥ len, then return undefined.
|
|
||||||
|
|
||||||
includes: [testTypedArray.js]
|
|
||||||
features: [TypedArray,TypedArray.prototype.item]
|
|
||||||
---*/
|
|
||||||
assert.sameValue(
|
|
||||||
typeof TypedArray.prototype.item,
|
|
||||||
'function',
|
|
||||||
'The value of `typeof TypedArray.prototype.item` is "function"'
|
|
||||||
);
|
|
||||||
|
|
||||||
testWithTypedArrayConstructors(TA => {
|
|
||||||
assert.sameValue(typeof TA.prototype.item, 'function', 'The value of `typeof TA.prototype.item` is "function"');
|
|
||||||
let a = new TA([]);
|
|
||||||
|
|
||||||
assert.sameValue(a.item(-2), undefined, 'a.item(-2) must return undefined'); // wrap around the end
|
|
||||||
assert.sameValue(a.item(0), undefined, 'a.item(0) must return undefined');
|
|
||||||
assert.sameValue(a.item(1), undefined, 'a.item(1) must return undefined');
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user