mirror of https://github.com/tc39/test262.git
WIP: Align detached buffer semantics with web reality
To support https://github.com/tc39/ecma262/pull/2164
This commit is contained in:
parent
52cb1d0c98
commit
36c2cd165f
|
@ -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');
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
23
test/built-ins/DataView/prototype/byteLength/instance-has-detached-buffer.js
vendored
Normal file
23
test/built-ins/DataView/prototype/byteLength/instance-has-detached-buffer.js
vendored
Normal file
|
@ -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;
|
||||
});
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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`');
|
||||
});
|
||||
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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)");
|
||||
});
|
||||
|
|
|
@ -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`');
|
||||
});
|
||||
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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]');
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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]");
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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`');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue