diff --git a/test/built-ins/TypedArrays/internals/Get/infinity-detached-buffer.js b/test/built-ins/TypedArrays/internals/Get/infinity-detached-buffer.js new file mode 100644 index 0000000000000000000000000000000000000000..3451ea24949ad0b5133bcf82602749f1526ba3c7 --- /dev/null +++ b/test/built-ins/TypedArrays/internals/Get/infinity-detached-buffer.js @@ -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; + }); +}); diff --git a/test/built-ins/TypedArrays/internals/GetOwnProperty/enumerate-detached-buffer.js b/test/built-ins/TypedArrays/internals/GetOwnProperty/enumerate-detached-buffer.js new file mode 100644 index 0000000000000000000000000000000000000000..b5ff13a34dfea83e0718ae3c18da31aa71c0dfc0 --- /dev/null +++ b/test/built-ins/TypedArrays/internals/GetOwnProperty/enumerate-detached-buffer.js @@ -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(); + } + }); +}); diff --git a/test/built-ins/TypedArrays/internals/HasProperty/infinity-with-detached-buffer.js b/test/built-ins/TypedArrays/internals/HasProperty/infinity-with-detached-buffer.js new file mode 100644 index 0000000000000000000000000000000000000000..4d2001f03f345f732e8dceac4772d4a3fda7f4f3 --- /dev/null +++ b/test/built-ins/TypedArrays/internals/HasProperty/infinity-with-detached-buffer.js @@ -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; + }); +});