diff --git a/test/built-ins/ArrayBuffer/prototype/byteLength/detached-buffer.js b/test/built-ins/ArrayBuffer/prototype/byteLength/detached-buffer.js index d5979c6dab..7be829e4a6 100644 --- a/test/built-ins/ArrayBuffer/prototype/byteLength/detached-buffer.js +++ b/test/built-ins/ArrayBuffer/prototype/byteLength/detached-buffer.js @@ -4,11 +4,9 @@ esid: sec-get-arraybuffer.prototype.bytelength description: Returns 0 if the buffer is detached info: | - 24.1.4.1 get ArrayBuffer.prototype.byteLength - - 1. Let O be the this value. + get ArrayBuffer.prototype.byteLength ... - 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + If IsDetachedBuffer(buffer) is true, return 0. ... includes: [detachArrayBuffer.js] ---*/ @@ -17,6 +15,4 @@ var ab = new ArrayBuffer(1); $DETACHBUFFER(ab); -assert.throws(TypeError, function() { - ab.byteLength; -}); +assert.sameValue(ab.byteLength, 0, 'The value of ab.byteLength is 0'); diff --git a/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js b/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js index 2867d8360e..6f26daf2d3 100644 --- a/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js +++ b/test/built-ins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js @@ -7,11 +7,18 @@ description: Throws a TypeError exception when `this` is a SharedArrayBuffer features: [SharedArrayBuffer] ---*/ -var getter = Object.getOwnPropertyDescriptor( +var byteLength = Object.getOwnPropertyDescriptor( ArrayBuffer.prototype, "byteLength" -).get; +); + +var getter = byteLength.get; +var sab = new SharedArrayBuffer(4); assert.throws(TypeError, function() { - var sab = new SharedArrayBuffer(4); getter.call(sab); }, "`this` cannot be a SharedArrayBuffer"); + +assert.throws(TypeError, function() { + Object.defineProperties(sab, { byteLength }); + sab.byteLength; +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/built-ins/DataView/prototype/byteLength/detached-buffer.js b/test/built-ins/DataView/prototype/byteLength/detached-buffer.js index 2733e64139..73eaafc84b 100644 --- a/test/built-ins/DataView/prototype/byteLength/detached-buffer.js +++ b/test/built-ins/DataView/prototype/byteLength/detached-buffer.js @@ -5,19 +5,19 @@ esid: sec-get-dataview.prototype.bytelength description: Throws a TypeError if the instance has a detached buffer info: | - 24.2.4.2 get DataView.prototype.byteLength + get DataView.prototype.byteLength ... - 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 6. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [detachArrayBuffer.js] ---*/ -var buffer = new ArrayBuffer(1); -var sample = new DataView(buffer, 0); +let buffer = new ArrayBuffer(1); +let dv = new DataView(buffer, 0); $DETACHBUFFER(buffer); -assert.throws(TypeError, function() { - sample.byteLength; +assert.throws(TypeError, () => { + dv.byteLength; }); diff --git a/test/built-ins/DataView/prototype/byteLength/instance-has-detached-buffer.js b/test/built-ins/DataView/prototype/byteLength/instance-has-detached-buffer.js new file mode 100644 index 0000000000..cac6c78e25 --- /dev/null +++ b/test/built-ins/DataView/prototype/byteLength/instance-has-detached-buffer.js @@ -0,0 +1,23 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-dataview.prototype.bytelength +description: Throws a TypeError if the instance has a detached buffer +info: | + get DataView.prototype.byteLength + ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [detachArrayBuffer.js] +---*/ + +let buffer = new ArrayBuffer(1); +let dv = new DataView(buffer, 0); + +$DETACHBUFFER(dv.buffer); + +assert.throws(TypeError, () => { + dv.byteLength; +}); diff --git a/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js index c81ad9ab89..888adae73c 100644 --- a/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js +++ b/test/built-ins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js @@ -3,36 +3,36 @@ /*--- esid: sec-%typedarray%.prototype.slice description: > - Throws a TypeError buffer is detached on Get custom constructor. Using other - targetType + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. info: | 22.2.3.24 %TypedArray%.prototype.slice ( start, end ) ... - 9. Let A be ? TypedArraySpeciesCreate(O, « count »). - ... - 14. If SameValue(srcType, targetType) is false, then - a. Let n be 0. - b. Repeat, while k < final - ... - ii. Let kValue be ? Get(O, Pk). - ... + Let A be ? TypedArraySpeciesCreate(O, « count »). + If count > 0, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Symbol.species, TypedArray] ---*/ testWithBigIntTypedArrayConstructors(function(TA) { + let counter = 0; var sample = new TA(1); sample.constructor = {}; sample.constructor[Symbol.species] = function(count) { var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + counter++; + assert.sameValue(count, 1, 'The value of `count` is 1'); $DETACHBUFFER(sample.buffer); return new other(count); }; assert.throws(TypeError, function() { + counter++; sample.slice(); - }, "step 14.b.ii - ? Get(O, Pk), O has a detached buffer"); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-realm.js index 52d2ad0950..4073f10387 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer-realm.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > - Throws a TypeError if object has valid numeric index and a detached buffer + Returns false if this has valid numeric index and a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc) @@ -20,17 +20,17 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, cross-realm, Reflect, TypedArray] ---*/ - var other = $262.createRealm().global; + var desc = { value: 0n, - configurable: false, + configurable: true, enumerable: true, writable: true }; @@ -38,10 +38,11 @@ var desc = { testWithBigIntTypedArrayConstructors(function(TA) { var OtherTA = other[TA.name]; var sample = new OtherTA(1); - $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.defineProperty(sample, '0', desc); - }); + assert.sameValue( + Reflect.defineProperty(sample, '0', desc), + false, + 'Reflect.defineProperty( sample, "0", {value: 0n, configurable: true, enumerable: true, writable: true} ) must return false' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js index 17417b995d..4b4202cfc3 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > - Throws a TypeError if object has valid numeric index and a detached buffer + Returns false if this has valid numeric index and a detached buffer info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc) ... @@ -19,13 +19,12 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Reflect, TypedArray] ---*/ - var desc = { value: 0n, configurable: false, @@ -43,92 +42,70 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.defineProperty(sample, "0", desc); - }, "Throws TypeError on valid numeric index if instance has a detached buffer"); - assert.sameValue( - Reflect.defineProperty(sample, "-1", desc), + Reflect.defineProperty(sample, '0', desc), false, - "Return false before Detached Buffer check when value is a negative number" + 'Reflect.defineProperty(sample, "0", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); assert.sameValue( - Reflect.defineProperty(sample, "1.1", desc), + Reflect.defineProperty(sample, '-1', desc), false, - "Return false before Detached Buffer check when value is not an integer" + 'Reflect.defineProperty(sample, "-1", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); assert.sameValue( - Reflect.defineProperty(sample, "-0", desc), + Reflect.defineProperty(sample, '1.1', desc), false, - "Return false before Detached Buffer check when value is -0" + 'Reflect.defineProperty(sample, "1.1", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); assert.sameValue( - Reflect.defineProperty(sample, "2", { - configurable: true, - enumerable: true, - writable: true, - value: obj - }), + Reflect.defineProperty(sample, '-0', desc), false, - "Return false before Detached Buffer check when desc configurable is true" + 'Reflect.defineProperty(sample, "-0", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); + assert.sameValue(Reflect.defineProperty(sample, '2', { + configurable: true, + enumerable: true, + writable: true, + value: obj + }), false, 'Reflect.defineProperty(sample, "2", {configurable: true, enumerable: true, writable: true, value: obj}) must return false'); + + assert.sameValue(Reflect.defineProperty(sample, '3', { + configurable: false, + enumerable: false, + writable: true, + value: obj + }), false, 'Reflect.defineProperty(sample, "3", {configurable: false, enumerable: false, writable: true, value: obj}) must return false'); + + assert.sameValue(Reflect.defineProperty(sample, '4', { + writable: false, + configurable: false, + enumerable: true, + value: obj + }), false, 'Reflect.defineProperty(sample, "4", {writable: false, configurable: false, enumerable: true, value: obj}) must return false'); + assert.sameValue( - Reflect.defineProperty(sample, "3", { - configurable: false, - enumerable: false, - writable: true, - value: obj - }), + Reflect.defineProperty(sample, '42', desc), false, - "Return false before Detached Buffer check when desc enumerable is false" + 'Reflect.defineProperty(sample, "42", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); assert.sameValue( - Reflect.defineProperty(sample, "4", { - writable: false, - configurable: false, - enumerable: true, - value: obj - }), + Reflect.defineProperty(sample, '43', desc), false, - "Return false before Detached Buffer check when desc writable is false" + 'Reflect.defineProperty(sample, "43", {value: 0n, configurable: false, enumerable: true, writable: true}) must return false' ); - assert.sameValue( - Reflect.defineProperty(sample, "42", desc), - false, - "Return false before Detached Buffer check when key == [[ArrayLength]]" - ); + assert.sameValue(Reflect.defineProperty(sample, '5', { + get: function() {} + }), false, 'Reflect.defineProperty(sample, "5", {get: function() {}}) must return false'); - assert.sameValue( - Reflect.defineProperty(sample, "43", desc), - false, - "Return false before Detached Buffer check when key > [[ArrayLength]]" - ); - - assert.sameValue( - Reflect.defineProperty(sample, "5", { - get: function() {} - }), - false, - "Return false before Detached Buffer check with accessor descriptor" - ); - - assert.sameValue( - Reflect.defineProperty(sample, "6", { - configurable: false, - enumerable: true, - writable: true - }), - true, - "Return true before Detached Buffer check when desc value is not present" - ); - - assert.throws(Test262Error, function() { - Reflect.defineProperty(sample, "7", {value: obj}); - }, "Return Abrupt before Detached Buffer check from ToNumber(desc.value)"); + assert.sameValue(Reflect.defineProperty(sample, '6', { + configurable: false, + enumerable: true, + writable: true + }), false, 'Reflect.defineProperty(sample, "6", {configurable: false, enumerable: true, writable: true}) must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js index 3e8241ca07..31fc7f3b81 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/key-is-numericindex.js @@ -11,32 +11,26 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - x. If Desc has a [[Writable]] field and if Desc.[[Writable]] is false, - return false. + v. If Desc has a [[Writable]] field and if Desc.[[Writable]] is false, + return false. ... includes: [testBigIntTypedArray.js, propertyHelper.js] features: [BigInt, Reflect, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 42n]); - assert.sameValue( - Reflect.defineProperty(sample, "0", { - value: 8n, - configurable: false, - enumerable: true, - writable: true - }), - true - ); + assert.sameValue(Reflect.defineProperty(sample, '0', { + value: 8n, + configurable: true, + enumerable: true, + writable: true + }), true, 'Reflect.defineProperty("new TA([42n, 42n])", "0", {value: 8n, configurable: true, enumerable: true, writable: true}) must return true'); - assert.sameValue(sample[0], 8n, "property value was set"); - var desc = Object.getOwnPropertyDescriptor(sample, "0"); - - assert.sameValue(desc.value, 8n, "desc.value"); - assert.sameValue(desc.writable, true, "property is writable"); - - verifyEnumerable(sample, "0"); - verifyNotConfigurable(sample, "0"); + assert.sameValue(sample[0], 8n, 'The value of sample[0] is 8n'); + var desc = Object.getOwnPropertyDescriptor(sample, '0'); + assert.sameValue(desc.value, 8n, 'The value of desc.value is 8n'); + assert.sameValue(desc.writable, true, 'The value of desc.writable is true'); + verifyEnumerable(sample, '0'); + verifyNotConfigurable(sample, '0'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js index 9c8a191e9f..52cc5ecae5 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js @@ -1,12 +1,11 @@ // Copyright (C) 2017 Mozilla Corporation. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > Defining a typed array element to a value that, when converted to the typed - array element type, detaches the typed array's underlying buffer, should - throw a TypeError and not modify the typed array. + array element type, detaches the typed array's underlying buffer, should return + false and not modify the typed array. info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc ) @@ -28,28 +27,23 @@ info: | includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Reflect, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { var ta = new TA([17n]); - var desc = - { - value: { - valueOf: function() { - $DETACHBUFFER(ta.buffer); - return 42n; - } + var desc = { + value: { + valueOf() { + $DETACHBUFFER(ta.buffer); + return 42n; } - }; + } + }; - assert.throws(TypeError, function() { - Reflect.defineProperty(ta, 0, desc); - }, - "detaching a ArrayBuffer during defining an element of a typed array " + - "viewing it should throw"); + assert.sameValue( + Reflect.defineProperty(ta, 0, desc), + false, + 'Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return false' + ); - assert.throws(TypeError, function() { - ta[0]; - }); + assert.sameValue(ta[0], undefined, 'The value of ta[0] is expected to equal `undefined`'); }); - diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js index acff6e44e7..8a660029d7 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer-realm.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > - Throws a TypeError if object has valid numeric index and a detached buffer + Returns false if this has valid numeric index and a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc) @@ -20,8 +20,8 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [cross-realm, Reflect, TypedArray] @@ -30,7 +30,7 @@ features: [cross-realm, Reflect, TypedArray] var other = $262.createRealm().global; var desc = { value: 0, - configurable: false, + configurable: true, enumerable: true, writable: true }; @@ -41,7 +41,9 @@ testWithTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.defineProperty(sample, '0', desc); - }); + assert.sameValue( + Reflect.defineProperty(sample, '0', desc), + false, + 'Reflect.defineProperty(sample, "0", {value: 0, configurable: true, enumerable: true, writable: true}) must return false' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js index a1039636f7..02131e59f3 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > - Throws a TypeError if object has valid numeric index and a detached buffer + Returns false if this has valid numeric index and a detached buffer info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc) ... @@ -19,8 +19,8 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [Reflect, TypedArray] @@ -43,26 +43,28 @@ testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.defineProperty(sample, "0", desc); - }, "Throws TypeError on valid numeric index if instance has a detached buffer"); + assert.sameValue( + Reflect.defineProperty(sample, "0", desc), + false, + 'Reflect.defineProperty(sample, "0", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' + ); assert.sameValue( Reflect.defineProperty(sample, "-1", desc), false, - "Return false before Detached Buffer check when value is a negative number" + 'Reflect.defineProperty(sample, "-1", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' ); assert.sameValue( Reflect.defineProperty(sample, "1.1", desc), false, - "Return false before Detached Buffer check when value is not an integer" + 'Reflect.defineProperty(sample, "1.1", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' ); assert.sameValue( Reflect.defineProperty(sample, "-0", desc), false, - "Return false before Detached Buffer check when value is -0" + 'Reflect.defineProperty(sample, "-0", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' ); assert.sameValue( @@ -73,7 +75,7 @@ testWithTypedArrayConstructors(function(TA) { value: obj }), false, - "Return false before Detached Buffer check when desc configurable is true" + 'Reflect.defineProperty(sample, "2", {configurable: true, enumerable: true, writable: true, value: obj}) must return false' ); assert.sameValue( @@ -84,7 +86,7 @@ testWithTypedArrayConstructors(function(TA) { value: obj }), false, - "Return false before Detached Buffer check when desc enumerable is false" + 'Reflect.defineProperty(sample, "3", {configurable: false, enumerable: false, writable: true, value: obj}) must return false' ); assert.sameValue( @@ -95,19 +97,19 @@ testWithTypedArrayConstructors(function(TA) { value: obj }), false, - "Return false before Detached Buffer check when desc writable is false" + 'Reflect.defineProperty("new TA(42)", "4", {writable: false, configurable: false, enumerable: true, value: obj}) must return false' ); assert.sameValue( Reflect.defineProperty(sample, "42", desc), false, - "Return false before Detached Buffer check when key == [[ArrayLength]]" + 'Reflect.defineProperty(sample, "42", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' ); assert.sameValue( Reflect.defineProperty(sample, "43", desc), false, - "Return false before Detached Buffer check when key > [[ArrayLength]]" + 'Reflect.defineProperty(sample, "43", {value: 0, configurable: false, enumerable: true, writable: true} ) must return false' ); assert.sameValue( @@ -115,7 +117,7 @@ testWithTypedArrayConstructors(function(TA) { get: function() {} }), false, - "Return false before Detached Buffer check with accessor descriptor" + 'Reflect.defineProperty(sample, "5", {get: function() {}}) must return false' ); assert.sameValue( @@ -124,11 +126,7 @@ testWithTypedArrayConstructors(function(TA) { enumerable: true, writable: true }), - true, - "Return true before Detached Buffer check when desc value is not present" + false, + 'Reflect.defineProperty(sample, "6", {configurable: false, enumerable: true, writable: true}) must return false' ); - - assert.throws(Test262Error, function() { - Reflect.defineProperty(sample, "7", {value: obj}); - }, "Return Abrupt before Detached Buffer check from ToNumber(desc.value)"); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js index 1940e5cde3..2db4582ce7 100644 --- a/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js @@ -6,7 +6,7 @@ esid: sec-integer-indexed-exotic-objects-defineownproperty-p-desc description: > Defining a typed array element to a value that, when converted to the typed array element type, detaches the typed array's underlying buffer, should - throw a TypeError and not modify the typed array. + return false and not modify the typed array. info: | 9.4.5.3 [[DefineOwnProperty]] ( P, Desc ) @@ -35,21 +35,18 @@ testWithTypedArrayConstructors(function(TA) { var desc = { value: { - valueOf: function() { + valueOf() { $DETACHBUFFER(ta.buffer); return 42; } } }; - assert.throws(TypeError, function() { - Reflect.defineProperty(ta, 0, desc); - }, - "detaching a ArrayBuffer during defining an element of a typed array " + - "viewing it should throw"); - - assert.throws(TypeError, function() { - ta[0]; - }); + assert.sameValue( + Reflect.defineProperty(ta, 0, desc), + false, + 'Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42;}}} ) must return false' + ); + assert.sameValue(ta[0], undefined, 'The value of ta[0] is expected to equal `undefined`'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer-realm.js index 91c06732bc..36dd497d4b 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer-realm.js @@ -3,8 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-getownproperty-p description: > - Throws a TypeError if this has a detached buffer (honoring the Realm of the - current execution context) + Returned undefined if this has a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.1 [[GetOwnProperty]] ( P ) @@ -12,14 +11,15 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). + ii. If value is undefined, return undefined. ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, cross-realm, TypedArray] @@ -33,7 +33,9 @@ testWithBigIntTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Object.getOwnPropertyDescriptor(sample, 0); - }); + assert.sameValue( + Object.getOwnPropertyDescriptor(sample, 0), + undefined, + 'Object.getOwnPropertyDescriptor("new OtherTA(1)", 0) must return undefined' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer.js index 5f14f03170..34aa1c0d85 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/detached-buffer.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-integer-indexed-exotic-objects-getownproperty-p -description: Throws a TypeError if this has a detached buffer +description: Returns undefined if this has a detached buffer info: | 9.4.5.1 [[GetOwnProperty]] ( P ) @@ -10,14 +10,15 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). + ii. If value is undefined, return undefined. ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] @@ -27,7 +28,9 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Object.getOwnPropertyDescriptor(sample, 0); - }); + assert.sameValue( + Object.getOwnPropertyDescriptor(sample, 0), + undefined, + 'Object.getOwnPropertyDescriptor(sample, 0) must return undefined' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js index 9523e3a5fd..177c750538 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js @@ -10,13 +10,13 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be O.[[ViewedArrayBuffer]]. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return undefined. ... 13.7.5.15 EnumerateObjectProperties (O) @@ -34,9 +34,9 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - for (var key in sample) { - throw new Test262Error(); - } - }); + let count = 0; + for (var key in sample) { + count++; + } + assert.sameValue(count, 0, 'The value of `count` is 0'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/index-prop-desc.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/index-prop-desc.js index ad44eb8d3c..8f023b8d28 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/index-prop-desc.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/index-prop-desc.js @@ -13,24 +13,21 @@ info: | b. If numericIndex is not undefined, then ... iii. Return a PropertyDescriptor{[[Value]]: value, [[Writable]]: true, - [[Enumerable]]: true, [[Configurable]]: false}. + [[Enumerable]]: true, [[Configurable]]: true}. ... includes: [testBigIntTypedArray.js, propertyHelper.js] features: [BigInt, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); - var desc0 = Object.getOwnPropertyDescriptor(sample, 0); - assert.sameValue(desc0.value, 42n, "value", "desc0.value === 42"); - assert.sameValue(desc0.writable, true, "index descriptor is writable [0]"); - verifyEnumerable(sample, "0", "index descriptor is enumerable [0]"); - verifyNotConfigurable(sample, "0", "index descriptor is not configurable [0]"); - + assert.sameValue(desc0.value, 42n, 'The value of desc0.value is 42n'); + assert.sameValue(desc0.writable, true, 'The value of desc0.writable is true'); + verifyEnumerable(sample, '0', 'index descriptor is enumerable [0]'); + verifyConfigurable(sample, '0', 'index descriptor is configurable [0]'); var desc1 = Object.getOwnPropertyDescriptor(sample, 1); - assert.sameValue(desc1.value, 43n, "value", "desc1.value === 43"); - assert.sameValue(desc1.writable, true, "index descriptor is writable [1]"); - verifyEnumerable(sample, "1", "index descriptor is enumerable [1]"); - verifyNotConfigurable(sample, "1", "index descriptor is not configurable [1]"); + assert.sameValue(desc1.value, 43n, 'The value of desc1.value is 43n'); + assert.sameValue(desc1.writable, true, 'The value of desc1.writable is true'); + verifyEnumerable(sample, '1', 'index descriptor is enumerable [1]'); + verifyConfigurable(sample, '1', 'index descriptor is configurable [1]'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js index 79a113064a..6cf10779a6 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer-realm.js @@ -3,8 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-getownproperty-p description: > - Throws a TypeError if this has a detached buffer (honoring the Realm of the - current execution context) + Returned undefined if this has a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.1 [[GetOwnProperty]] ( P ) @@ -12,15 +11,16 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). + ii. If value is undefined, return undefined. ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + includes: [testTypedArray.js, detachArrayBuffer.js] features: [cross-realm, TypedArray] ---*/ @@ -33,7 +33,9 @@ testWithTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Object.getOwnPropertyDescriptor(sample, 0); - }); + assert.sameValue( + Object.getOwnPropertyDescriptor(sample, 0), + undefined, + 'Object.getOwnPropertyDescriptor(sample, 0) must return undefined' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js index 6675d13076..b9839533d2 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/detached-buffer.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-integer-indexed-exotic-objects-getownproperty-p -description: Throws a TypeError if this has a detached buffer +description: Returns undefined if this has a detached buffer info: | 9.4.5.1 [[GetOwnProperty]] ( P ) @@ -10,14 +10,15 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). + ii. If value is undefined, return undefined. ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] @@ -27,7 +28,9 @@ testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Object.getOwnPropertyDescriptor(sample, 0); - }); + assert.sameValue( + Object.getOwnPropertyDescriptor(sample, 0), + undefined, + 'Object.getOwnPropertyDescriptor(sample, 0) must return undefined' + ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js index 40d7630dd6..97fc9aa0ce 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js @@ -10,13 +10,13 @@ info: | 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). + i. Let value be ! IntegerIndexedElementGet(O, numericIndex). ... - 9.4.5.8 IntegerIndexedElementGet ( O, index ) + IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be O.[[ViewedArrayBuffer]]. - 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return undefined. ... 13.7.5.15 EnumerateObjectProperties (O) @@ -34,9 +34,9 @@ testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - for (var key in sample) { - throw new Test262Error(); - } - }); + let count = 0; + for (var key in sample) { + count++; + } + assert.sameValue(count, 0, 'The value of `count` is 0'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js index fe7f1eca26..c0caeb505e 100644 --- a/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js +++ b/test/built-ins/TypedArrayConstructors/internals/GetOwnProperty/index-prop-desc.js @@ -23,14 +23,14 @@ testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); var desc0 = Object.getOwnPropertyDescriptor(sample, 0); - assert.sameValue(desc0.value, 42, "value", "desc0.value === 42"); - assert.sameValue(desc0.writable, true, "index descriptor is writable [0]"); + assert.sameValue(desc0.value, 42, 'The value of desc0.value is 42'); + assert.sameValue(desc0.writable, true, 'The value of desc0.writable is true'); verifyEnumerable(sample, "0", "index descriptor is enumerable [0]"); - verifyNotConfigurable(sample, "0", "index descriptor is not configurable [0]"); + verifyConfigurable(sample, "0", "index descriptor is configurable [0]"); var desc1 = Object.getOwnPropertyDescriptor(sample, 1); - assert.sameValue(desc1.value, 43, "value", "desc1.value === 43"); - assert.sameValue(desc1.writable, true, "index descriptor is writable [1]"); + assert.sameValue(desc1.value, 43, 'The value of desc1.value is 43'); + assert.sameValue(desc1.writable, true, 'The value of desc1.writable is true'); verifyEnumerable(sample, "1", "index descriptor is enumerable [1]"); - verifyNotConfigurable(sample, "1", "index descriptor is not configurable [1]"); + verifyConfigurable(sample, "1", "index descriptor is configurable [1]"); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js index b334a3888d..ffbd259f92 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/abrupt-from-ordinary-has-parent-hasproperty.js @@ -10,8 +10,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... 9.1.7.1 OrdinaryHasProperty (O, P) @@ -42,22 +42,22 @@ testWithBigIntTypedArrayConstructors(function(TA) { assert.sameValue( Reflect.has(sample, 0), true, - "OrdinaryHasProperty does not affect numericIndex properties [0]" + 'Reflect.has(sample, 0) must return true' ); assert.sameValue( Reflect.has(sample, 1), false, - "OrdinaryHasProperty does not affect numericIndex properties [1]" + 'Reflect.has(sample, 1) must return false' ); assert.throws(Test262Error, function() { Reflect.has(sample, "foo"); - }, "Return abrupt from parent's [[HasProperty]] 'foo'"); + }, '`Reflect.has(sample, "foo")` throws Test262Error'); Object.defineProperty(sample, "foo", { value: 42 }); assert.sameValue( Reflect.has(sample, "foo"), true, - "trap is not triggered if [[GetOwnProperty]] returns a defined value" + 'Reflect.has(sample, "foo") must return true' ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer-realm.js index 3870e5282a..7ef108271e 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer-realm.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-hasproperty-p description: > - Throws a TypeError if this has a detached buffer (honoring the Realm of the + Returns false if this has a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.2 [[HasProperty]](P) @@ -12,8 +12,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, cross-realm, Reflect, TypedArray] @@ -27,7 +27,5 @@ testWithBigIntTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.has(sample, '0'); - }, '0'); + assert.sameValue(Reflect.has(sample, '0'), false, 'Reflect.has(sample, "0") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer.js index d78265e350..adba3fa3e5 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/detached-buffer.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-integer-indexed-exotic-objects-hasproperty-p -description: Throws a TypeError if this has a detached buffer +description: Returns false if this has a detached buffer info: | 9.4.5.2 [[HasProperty]](P) @@ -10,8 +10,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Reflect, TypedArray] @@ -21,15 +21,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.has(sample, "0"); - }, "0"); - - assert.throws(TypeError, function() { - Reflect.has(sample, "-0"); - }, "-0"); - - assert.throws(TypeError, function() { - Reflect.has(sample, "1.1"); - }, "1.1"); + assert.sameValue(Reflect.has(sample, "0"), false, 'Reflect.has(sample, "0") must return false'); + assert.sameValue(Reflect.has(sample, "-0"), false, 'Reflect.has(sample, "-0") must return false'); + assert.sameValue(Reflect.has(sample, "1.1"), false, 'Reflect.has(sample, "1.1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/indexed-value.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/indexed-value.js index 9133ae261a..1b8fdf18e9 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/indexed-value.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/indexed-value.js @@ -11,22 +11,16 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - iii. If IsInteger(numericIndex) is false, return false. - iv. If numericIndex = -0, return false. - v. If numericIndex < 0, return false. - vi. If numericIndex ≥ the value of O's [[ArrayLength]] internal slot, - return false. - vii. Return true. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. + iv. Return true. ... includes: [testBigIntTypedArray.js] features: [BigInt, Reflect, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); - - assert.sameValue(Reflect.has(sample, 0), true); - assert.sameValue(Reflect.has(sample, 1), true); + assert.sameValue(Reflect.has(sample, 0), true, 'Reflect.has(sample, 0) must return true'); + assert.sameValue(Reflect.has(sample, 1), true, 'Reflect.has(sample, 1) must return true'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js index 2e4cdb7aeb..4343743d31 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/infinity-with-detached-buffer.js @@ -1,6 +1,5 @@ // Copyright (C) 2017 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. - /*--- esid: sec-integer-indexed-exotic-objects-hasproperty-p description: > @@ -12,7 +11,7 @@ info: | 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. + ii. If IsDetachedBuffer(buffer) is true, return false. ... 7.1.16 CanonicalNumericIndexString ( argument ) @@ -25,12 +24,23 @@ flags: [noStrict] includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { - var sample = new TA(0); - $DETACHBUFFER(sample.buffer); + let count = 0; - assert.throws(TypeError, function() { - with (sample) Infinity; - }); + let n = { + valueOf() { + count++; + return 9n; + } + }; + + assert.sameValue(count, 0, 'The value of `count` is 0'); + let ta = new TA([n]); + assert.sameValue(count, 1, 'The value of `count` is 1'); + $DETACHBUFFER(ta.buffer); + + with (ta) { + Infinity; + assert.sameValue(count, 1, 'The value of `count` is 1'); + } }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-greater-than-last-index.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-greater-than-last-index.js index c1d721348e..e85de785a5 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-greater-than-last-index.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-greater-than-last-index.js @@ -11,8 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - vi. If numericIndex ≥ the value of O's [[ArrayLength]] internal slot, - return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testBigIntTypedArray.js] features: [BigInt, Reflect, TypedArray] @@ -24,5 +23,5 @@ TypedArray.prototype[1] = "test262"; testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "1"), false, "1"); + assert.sameValue(Reflect.has(sample, "1"), false, 'Reflect.has(sample, "1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-lower-than-zero.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-lower-than-zero.js index 0048a4f975..ab5adbda66 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-lower-than-zero.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-lower-than-zero.js @@ -11,7 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - v. If numericIndex < 0, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testBigIntTypedArray.js] features: [BigInt, Reflect, TypedArray] @@ -24,5 +24,5 @@ TypedArray.prototype[-1] = "test262"; testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "-1"), false, "-1"); + assert.sameValue(Reflect.has(sample, "-1"), false, 'Reflect.has(sample, "-1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-minus-zero.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-minus-zero.js index 0d6a1515f3..9150c03569 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-minus-zero.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/BigInt/key-is-minus-zero.js @@ -11,7 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - iv. If numericIndex = -0, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testBigIntTypedArray.js] features: [BigInt, Reflect, TypedArray] @@ -24,5 +24,5 @@ TypedArray.prototype["-0"] = "test262"; testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "-0"), false, "-0"); + assert.sameValue(Reflect.has(sample, "-0"), false, 'Reflect.has(sample, "-0") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js index c54b4cf20b..37b404fc6b 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/abrupt-from-ordinary-has-parent-hasproperty.js @@ -10,8 +10,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... 9.1.7.1 OrdinaryHasProperty (O, P) @@ -42,22 +42,22 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue( Reflect.has(sample, 0), true, - "OrdinaryHasProperty does not affect numericIndex properties [0]" + 'Reflect.has(sample, 0) must return true' ); assert.sameValue( Reflect.has(sample, 1), false, - "OrdinaryHasProperty does not affect numericIndex properties [1]" + 'Reflect.has(sample, 1) must return false' ); assert.throws(Test262Error, function() { Reflect.has(sample, "foo"); - }, "Return abrupt from parent's [[HasProperty]] 'foo'"); + }, '`Reflect.has(sample, "foo")` throws Test262Error'); Object.defineProperty(sample, "foo", { value: 42 }); assert.sameValue( Reflect.has(sample, "foo"), true, - "trap is not triggered if [[GetOwnProperty]] returns a defined value" + 'Reflect.has(sample, "foo") must return true' ); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js index aae6149e2b..7b58ee6ee6 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer-realm.js @@ -3,8 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-hasproperty-p description: > - Throws a TypeError if this has a detached buffer (honoring the Realm of the - current execution context) + Returns false if this has a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.2 [[HasProperty]](P) @@ -12,8 +11,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [cross-realm, Reflect, TypedArray] @@ -27,7 +26,5 @@ testWithTypedArrayConstructors(function(TA) { $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.has(sample, '0'); - }, '0'); + assert.sameValue(Reflect.has(sample, '0'), false, 'Reflect.has(sample, "0") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js index 9085dc3ab2..4f942fb302 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/detached-buffer.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- esid: sec-integer-indexed-exotic-objects-hasproperty-p -description: Throws a TypeError if this has a detached buffer +description: Return false if this has a detached buffer info: | 9.4.5.2 [[HasProperty]](P) @@ -10,8 +10,8 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [Reflect, TypedArray] @@ -21,15 +21,7 @@ testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); - assert.throws(TypeError, function() { - Reflect.has(sample, "0"); - }, "0"); - - assert.throws(TypeError, function() { - Reflect.has(sample, "-0"); - }, "-0"); - - assert.throws(TypeError, function() { - Reflect.has(sample, "1.1"); - }, "1.1"); + assert.sameValue(Reflect.has(sample, "0"), false, 'Reflect.has(sample, "0") must return false'); + assert.sameValue(Reflect.has(sample, "-0"), false, 'Reflect.has(sample, "-0") must return false'); + assert.sameValue(Reflect.has(sample, "1.1"), false, 'Reflect.has(sample, "1.1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js index 5a3b0482ac..7f69a2f2d1 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/indexed-value.js @@ -11,14 +11,10 @@ info: | 3. If Type(P) is String, then a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then - i. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - ii. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - iii. If IsInteger(numericIndex) is false, return false. - iv. If numericIndex = -0, return false. - v. If numericIndex < 0, return false. - vi. If numericIndex ≥ the value of O's [[ArrayLength]] internal slot, - return false. - vii. Return true. + i. Let buffer be O.[[ViewedArrayBuffer]]. + ii. If IsDetachedBuffer(buffer) is true, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. + iv. Return true. ... includes: [testTypedArray.js] features: [Reflect, TypedArray] @@ -27,6 +23,6 @@ features: [Reflect, TypedArray] testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); - assert.sameValue(Reflect.has(sample, 0), true); - assert.sameValue(Reflect.has(sample, 1), true); + assert.sameValue(Reflect.has(sample, 0), true, 'Reflect.has("new TA([42, 43])", 0) must return true'); + assert.sameValue(Reflect.has(sample, 1), true, 'Reflect.has("new TA([42, 43])", 1) must return true'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js index 7a79bec7b9..6d4329a5df 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/infinity-with-detached-buffer.js @@ -12,7 +12,7 @@ info: | 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. + ii. If IsDetachedBuffer(buffer) is true, return false. ... 7.1.16 CanonicalNumericIndexString ( argument ) @@ -27,10 +27,24 @@ features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(TA) { - var sample = new TA(0); - $DETACHBUFFER(sample.buffer); + let count = 0; + let n = { + valueOf() { + count++; + return 9; + } + }; - assert.throws(TypeError, function() { - with (sample) Infinity; - }); + assert.sameValue(count, 0, 'The value of `count` is 0'); + + let ta = new TA([n]); + + assert.sameValue(count, 1, 'The value of `count` is 1'); + + $DETACHBUFFER(ta.buffer); + + with (ta) { + Infinity; + assert.sameValue(count, 1, 'The value of `count` is 1'); + } }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js index 630c211c1a..37eb252693 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-greater-than-last-index.js @@ -11,8 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - vi. If numericIndex ≥ the value of O's [[ArrayLength]] internal slot, - return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testTypedArray.js] features: [Reflect, TypedArray] @@ -24,5 +23,5 @@ TypedArray.prototype[1] = "test262"; testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "1"), false, "1"); + assert.sameValue(Reflect.has(sample, "1"), false, 'Reflect.has(sample, "1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js index 8bda094cf0..b73ed00781 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-lower-than-zero.js @@ -11,7 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - v. If numericIndex < 0, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testTypedArray.js] features: [Reflect, TypedArray] @@ -24,5 +24,5 @@ TypedArray.prototype[-1] = "test262"; testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "-1"), false, "-1"); + assert.sameValue(Reflect.has(sample, "-1"), false, 'Reflect.has(sample, "-1") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js index 9364e89b51..83d11837d4 100644 --- a/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js +++ b/test/built-ins/TypedArrayConstructors/internals/HasProperty/key-is-minus-zero.js @@ -11,7 +11,7 @@ info: | a. Let numericIndex be ! CanonicalNumericIndexString(P). b. If numericIndex is not undefined, then ... - iv. If numericIndex = -0, return false. + iii. If ! IsValidIntegerIndex(O, numericIndex) is false, return false. ... includes: [testTypedArray.js] features: [Reflect, TypedArray] @@ -24,5 +24,5 @@ TypedArray.prototype["-0"] = "test262"; testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); - assert.sameValue(Reflect.has(sample, "-0"), false, "-0"); + assert.sameValue(Reflect.has(sample, "-0"), false, 'Reflect.has(sample, "-0") must return false'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js b/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js index f5e15d83eb..2f5722d88e 100644 --- a/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js +++ b/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer-realm.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-set-p-v-receiver description: > - Throws a TypeError if key has a numeric index and object has a detached + Returns false if key has a numeric index and object has a detached buffer (honoring the Realm of the current execution context) info: | 9.4.5.5 [[Set]] ( P, V, Receiver) @@ -17,24 +17,23 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - ... - 3. Let numValue be ? ToNumber(value). - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... + Assert: O is an Integer-Indexed exotic object. + Assert: Type(index) is Number. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. + If ! IsValidIntegerIndex(O, index) is false, return false. + includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, cross-realm, TypedArray] ---*/ - var other = $262.createRealm().global; testWithBigIntTypedArrayConstructors(function(TA) { var OtherTA = other[TA.name]; var sample = new OtherTA(1); - $DETACHBUFFER(sample.buffer); - - assert.throws(TypeError, function() { - sample[0] = 0n; - }); + sample[0] = 0n; + assert.sameValue(sample[0], undefined, 'The value of sample[0] is expected to equal `undefined`'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js b/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js index 614f7779cb..97cabc9831 100644 --- a/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js +++ b/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/detached-buffer.js @@ -3,7 +3,7 @@ /*--- esid: sec-integer-indexed-exotic-objects-set-p-v-receiver description: > - Throws a TypeError if key has a numeric index and object has a detached buffer + Returns false if key has a numeric index and object has a detached buffer info: | 9.4.5.5 [[Set]] ( P, V, Receiver) @@ -16,42 +16,26 @@ info: | 9.4.5.9 IntegerIndexedElementSet ( O, index, value ) - ... - 3. Let numValue be ? ToNumber(value). - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. - 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. - ... + Assert: O is an Integer-Indexed exotic object. + Assert: Type(index) is Number. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, return false. + If ! IsValidIntegerIndex(O, index) is false, return false. + includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ - testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n]); $DETACHBUFFER(sample.buffer); - - assert.throws(TypeError, function() { - sample[0] = 1n; - }, "valid numeric index"); - - assert.throws(TypeError, function() { - sample["1.1"] = 1n; - }, "detach buffer runs before checking for 1.1"); - - assert.throws(TypeError, function() { - sample["-0"] = 1n; - }, "detach buffer runs before checking for -0"); - - assert.throws(TypeError, function() { - sample["-1"] = 1n; - }, "detach buffer runs before checking for -1"); - - assert.throws(TypeError, function() { - sample["1"] = 1n; - }, "detach buffer runs before checking for key == length"); - - assert.throws(TypeError, function() { - sample["2"] = 1n; - }, "detach buffer runs before checking for key > length"); + assert.sameValue(sample[0] = 1n, false, '`sample[0] = 1n` is false'); + assert.sameValue(sample['1.1'] = 1n, false, '`sample["1.1"] = 1n` is false'); + assert.sameValue(sample['-0'] = 1n, false, '`sample["-0"] = 1n` is false'); + assert.sameValue(sample['-1'] = 1n, false, '`sample["-1"] = 1n` is false'); + assert.sameValue(sample['1'] = 1n, false, '`sample["1"] = 1n` is false'); + assert.sameValue(sample['2'] = 1n, false, '`sample["2"] = 1n` is false'); var obj = { valueOf: function() { @@ -60,6 +44,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { }; assert.throws(Test262Error, function() { - sample["0"] = obj; - }, "ToNumber(value) is called before detached buffer check"); + sample['0'] = obj; + }, '`sample["0"] = obj` throws Test262Error'); }); diff --git a/test/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js b/test/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js index 60c85e77f3..4de9c0eadb 100644 --- a/test/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js +++ b/test/built-ins/TypedArrayConstructors/internals/Set/bigint-tonumber.js @@ -50,14 +50,10 @@ info: | includes: [testTypedArray.js] features: [BigInt, TypedArray] ---*/ - -var typedArray; - testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(1); - typedArray = new TA(1); - assert.throws(TypeError, function() { - typedArray[0] = 1n; - }); - }); - + assert.throws(TypeError, function() { + typedArray[0] = 1n; + }, '`typedArray[0] = 1n` throws TypeError'); +});