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 esid: sec-integer-indexed-exotic-objects-delete-p
description: > description: >
Use OrginaryDelete if key is not a CanonicalNumericIndex Use OrdinaryDelete if key is not a CanonicalNumericIndex
info: | info: |
[[Delete]] (P) [[Delete]] (P)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,45 +3,34 @@
/*--- /*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: > 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: | 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] includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([42n]); let sample = new TA(1);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
sample[0]; assert.sameValue(sample["1.1"], undefined, 'The value of sample["1.1"] is expected to equal `undefined`');
}, "valid numeric index"); 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.throws(TypeError, function() { assert.sameValue(sample["1"], undefined, 'The value of sample["1"] is expected to equal `undefined`');
sample["1.1"]; assert.sameValue(sample["2"], undefined, 'The value of sample["2"] is expected to equal `undefined`');
}, "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");
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,30 +3,34 @@
/*--- /*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: > 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) buffer (honoring the Realm of the current execution context)
info: | info: |
9.4.5.4 [[Get]] (P, Receiver) [[Get]] ( P, Receiver )
... If Type(P) is String, then
2. If Type(P) is String, then Let numericIndex be ! CanonicalNumericIndexString(P).
a. Let numericIndex be ! CanonicalNumericIndexString(P). If numericIndex is not undefined, then
b. If numericIndex is not undefined, then Return ! IntegerIndexedElementGet(O, numericIndex).
i. 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] includes: [testTypedArray.js, detachArrayBuffer.js]
features: [cross-realm, TypedArray] features: [cross-realm, TypedArray]
---*/ ---*/
var other = $262.createRealm().global; let other = $262.createRealm().global;
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var OtherTA = other[TA.name]; let OtherTA = other[TA.name];
var sample = new OtherTA(1); let sample = new OtherTA(1);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
sample[0];
});
}); });

View File

@ -3,16 +3,22 @@
/*--- /*---
esid: sec-integer-indexed-exotic-objects-get-p-receiver esid: sec-integer-indexed-exotic-objects-get-p-receiver
description: > 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: | 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] includes: [testTypedArray.js, detachArrayBuffer.js]
features: [TypedArray] features: [TypedArray]
---*/ ---*/
@ -21,27 +27,10 @@ testWithTypedArrayConstructors(function(TA) {
var sample = new TA([42]); var sample = new TA([42]);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`');
sample[0]; assert.sameValue(sample["1.1"], undefined, 'The value of sample["1.1"] is expected to equal `undefined`');
}, "valid numeric index"); 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.throws(TypeError, function() { assert.sameValue(sample["1"], undefined, 'The value of sample["1"] is expected to equal `undefined`');
sample["1.1"]; assert.sameValue(sample["2"], undefined, 'The value of sample["2"] is expected to equal `undefined`');
}, "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");
}); });

View File

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

View File

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

View File

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

View File

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

View File

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