IntegerIndexedElementGet ( O, index )

This commit is contained in:
Rick Waldron 2020-09-30 12:04:56 -04:00
parent 5f299199c6
commit 0bb8fe8aba
22 changed files with 102 additions and 119 deletions

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is a Symbol
Use OrdinaryDelete if key is a Symbol
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex
Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: |
[[Delete]] (P)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-delete-p
description: >
Use OrginaryDelete if key is a Symbol
Use OrdinaryDelete if key is a Symbol
info: |
[[Delete]] (P)

View File

@ -3,30 +3,34 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Throws a TypeError if key has a numeric index and object has a detached
Returns undefined if key has a numeric index and object has a detached
buffer (honoring the Realm of the current execution context)
info: |
9.4.5.4 [[Get]] (P, Receiver)
[[Get]] ( P, Receiver )
...
2. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Return ? IntegerIndexedElementGet(O, numericIndex).
If Type(P) is String, then
Let numericIndex be ! CanonicalNumericIndexString(P).
If numericIndex is not undefined, then
Return ! IntegerIndexedElementGet(O, numericIndex).
IntegerIndexedElementGet ( O, index )
Assert: O is an Integer-Indexed exotic object.
Assert: Type(index) is Number.
Let buffer be O.[[ViewedArrayBuffer]].
If IsDetachedBuffer(buffer) is true, return undefined.
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, cross-realm, TypedArray]
---*/
var other = $262.createRealm().global;
let other = $262.createRealm().global;
testWithBigIntTypedArrayConstructors(function(TA) {
var OtherTA = other[TA.name];
var sample = new OtherTA(1);
let OtherTA = other[TA.name];
let sample = new OtherTA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample[0];
});
assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
});

View File

@ -3,45 +3,34 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Throws a TypeError if key has a numeric index and object has a detached buffer
Returns undefined if key has a numeric index and object has a detached buffer
info: |
9.4.5.4 [[Get]] (P, Receiver)
[[Get]] ( P, Receiver )
If Type(P) is String, then
Let numericIndex be ! CanonicalNumericIndexString(P).
If numericIndex is not undefined, then
Return ! IntegerIndexedElementGet(O, numericIndex).
IntegerIndexedElementGet ( O, index )
Assert: O is an Integer-Indexed exotic object.
Assert: Type(index) is Number.
Let buffer be O.[[ViewedArrayBuffer]].
If IsDetachedBuffer(buffer) is true, return undefined.
...
2. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Return ? IntegerIndexedElementGet(O, numericIndex).
...
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([42n]);
let sample = new TA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample[0];
}, "valid numeric index");
assert.throws(TypeError, function() {
sample["1.1"];
}, "detach buffer runs before checking for 1.1");
assert.throws(TypeError, function() {
sample["-0"];
}, "detach buffer runs before checking for -0");
assert.throws(TypeError, function() {
sample["-1"];
}, "detach buffer runs before checking for -1");
assert.throws(TypeError, function() {
sample["1"];
}, "detach buffer runs before checking for key == length");
assert.throws(TypeError, function() {
sample["2"];
}, "detach buffer runs before checking for key > length");
assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
assert.sameValue(sample["1.1"], undefined, 'The value of sample["1.1"] is expected to equal `undefined`');
assert.sameValue(sample["-0"], undefined, 'The value of sample["-0"] is expected to equal `undefined`');
assert.sameValue(sample["-1"], undefined, 'The value of sample["-1"] is expected to equal `undefined`');
assert.sameValue(sample["1"], undefined, 'The value of sample["1"] is expected to equal `undefined`');
assert.sameValue(sample["2"], undefined, 'The value of sample["2"] is expected to equal `undefined`');
});

View File

@ -31,10 +31,8 @@ features: [BigInt, TypedArray]
---*/
testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(0);
let sample = new TA(0);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.Infinity;
});
assert.sameValue(sample.Infinity, undefined, 'The value of sample.Infinity is expected to equal `undefined`');
});

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if numeric key is not a CanonicalNumericIndex
Use OrdinaryGet if numeric key is not a CanonicalNumericIndex
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Returns abrupt from OrginaryGet when key is not a numeric index
Returns abrupt from OrdinaryGet when key is not a numeric index
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if key is not a CanonicalNumericIndex
Use OrdinaryGet if key is not a CanonicalNumericIndex
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if key is a Symbol
Use OrdinaryGet if key is a Symbol
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,30 +3,34 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Throws a TypeError if key has a numeric index and object has a detached
Returns undefined if key has a numeric index and object has a detached
buffer (honoring the Realm of the current execution context)
info: |
9.4.5.4 [[Get]] (P, Receiver)
[[Get]] ( P, Receiver )
...
2. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Return ? IntegerIndexedElementGet(O, numericIndex).
If Type(P) is String, then
Let numericIndex be ! CanonicalNumericIndexString(P).
If numericIndex is not undefined, then
Return ! IntegerIndexedElementGet(O, numericIndex).
IntegerIndexedElementGet ( O, index )
Assert: O is an Integer-Indexed exotic object.
Assert: Type(index) is Number.
Let buffer be O.[[ViewedArrayBuffer]].
If IsDetachedBuffer(buffer) is true, return undefined.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [cross-realm, TypedArray]
---*/
var other = $262.createRealm().global;
let other = $262.createRealm().global;
testWithTypedArrayConstructors(function(TA) {
var OtherTA = other[TA.name];
var sample = new OtherTA(1);
let OtherTA = other[TA.name];
let sample = new OtherTA(1);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample[0];
});
assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
});

View File

@ -3,16 +3,22 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Throws a TypeError if key has a numeric index and object has a detached buffer
Returns undefined if key has a numeric index and object has a detached buffer
info: |
9.4.5.4 [[Get]] (P, Receiver)
[[Get]] ( P, Receiver )
If Type(P) is String, then
Let numericIndex be ! CanonicalNumericIndexString(P).
If numericIndex is not undefined, then
Return ! IntegerIndexedElementGet(O, numericIndex).
IntegerIndexedElementGet ( O, index )
Assert: O is an Integer-Indexed exotic object.
Assert: Type(index) is Number.
Let buffer be O.[[ViewedArrayBuffer]].
If IsDetachedBuffer(buffer) is true, return undefined.
...
2. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Return ? IntegerIndexedElementGet(O, numericIndex).
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
@ -21,27 +27,10 @@ testWithTypedArrayConstructors(function(TA) {
var sample = new TA([42]);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample[0];
}, "valid numeric index");
assert.throws(TypeError, function() {
sample["1.1"];
}, "detach buffer runs before checking for 1.1");
assert.throws(TypeError, function() {
sample["-0"];
}, "detach buffer runs before checking for -0");
assert.throws(TypeError, function() {
sample["-1"];
}, "detach buffer runs before checking for -1");
assert.throws(TypeError, function() {
sample["1"];
}, "detach buffer runs before checking for key == length");
assert.throws(TypeError, function() {
sample["2"];
}, "detach buffer runs before checking for key > length");
assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
assert.sameValue(sample["1.1"], undefined, 'The value of sample["1.1"] is expected to equal `undefined`');
assert.sameValue(sample["-0"], undefined, 'The value of sample["-0"] is expected to equal `undefined`');
assert.sameValue(sample["-1"], undefined, 'The value of sample["-1"] is expected to equal `undefined`');
assert.sameValue(sample["1"], undefined, 'The value of sample["1"] is expected to equal `undefined`');
assert.sameValue(sample["2"], undefined, 'The value of sample["2"] is expected to equal `undefined`');
});

View File

@ -14,27 +14,26 @@ info: |
i. Return ? IntegerIndexedElementGet(O, numericIndex).
...
7.1.16 CanonicalNumericIndexString ( argument )
CanonicalNumericIndexString ( argument )
...
3. Let n be ! ToNumber(argument).
4. If SameValue(! ToString(n), argument) is false, return undefined.
5. Return n.
9.4.5.8 IntegerIndexedElementGet ( O, index )
...
3. Let buffer be O.[[ViewedArrayBuffer]].
4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
IntegerIndexedElementGet ( O, index )
Assert: O is an Integer-Indexed exotic object.
Assert: Type(index) is Number.
Let buffer be O.[[ViewedArrayBuffer]].
If IsDetachedBuffer(buffer) is true, return undefined.
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(0);
let sample = new TA(0);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.Infinity;
});
assert.sameValue(sample.Infinity, undefined, 'The value of sample.Infinity is expected to equal `undefined`');
});

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if numeric key is not a CanonicalNumericIndex
Use OrdinaryGet if numeric key is not a CanonicalNumericIndex
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Returns abrupt from OrginaryGet when key is not a numeric index
Returns abrupt from OrdinaryGet when key is not a numeric index
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if key is not a CanonicalNumericIndex
Use OrdinaryGet if key is not a CanonicalNumericIndex
info: |
9.4.5.4 [[Get]] (P, Receiver)

View File

@ -3,7 +3,7 @@
/*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: >
Use OrginaryGet if key is a Symbol
Use OrdinaryGet if key is a Symbol
info: |
9.4.5.4 [[Get]] (P, Receiver)