Add tests for accessing Infinity on detached typed arrays

This commit is contained in:
André Bargull 2017-12-08 13:22:34 -08:00 committed by Rick Waldron
parent 6b8bd307d2
commit 7f96cb10c1
3 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
id: sec-integerindexedelementget
info: >
"Infinity" is a canonical numeric string, test with access on detached buffer.
description: |
9.4.5.4 [[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).
...
7.1.16 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.
...
includes: [testTypedArray.js, detachArrayBuffer.js]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(0);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
sample.Infinity;
});
});

View File

@ -0,0 +1,41 @@
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
id: sec-integer-indexed-exotic-objects-getownproperty-p
info: Test for-in enumeration with detached buffer.
description: |
9.4.5.1 [[GetOwnProperty]] ( P )
...
3. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Let value be ? IntegerIndexedElementGet(O, numericIndex).
...
9.4.5.8 IntegerIndexedElementGet ( O, index )
...
3. Let buffer be O.[[ViewedArrayBuffer]].
4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
13.7.5.15 EnumerateObjectProperties (O)
...
EnumerateObjectProperties must obtain the own property keys of the
target object by calling its [[OwnPropertyKeys]] internal method.
Property attributes of the target object must be obtained by
calling its [[GetOwnProperty]] internal method.
includes: [testTypedArray.js, detachArrayBuffer.js]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(42);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
for (var key in sample) {
throw new Test262Error();
}
});
});

View File

@ -0,0 +1,35 @@
// Copyright (C) 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
id: sec-integer-indexed-exotic-objects-hasproperty-p
info: >
"Infinity" is a canonical numeric string, test with access on detached buffer.
description: |
9.4.5.2 [[HasProperty]]( P )
...
3. If Type(P) is String, then
a. Let numericIndex be ! CanonicalNumericIndexString(P).
b. If numericIndex is not undefined, then
i. Let buffer be O.[[ViewedArrayBuffer]].
ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
7.1.16 CanonicalNumericIndexString ( argument )
...
3. Let n be ! ToNumber(argument).
4. If SameValue(! ToString(n), argument) is false, return undefined.
5. Return n.
flags: [noStrict]
includes: [testTypedArray.js, detachArrayBuffer.js]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA(0);
$DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() {
with (sample) Infinity;
});
});