mirror of https://github.com/tc39/test262.git
Align detached buffer semantics with web reality, R1
This commit is contained in:
parent
23f30e527a
commit
f2a8384d4d
|
@ -27,7 +27,7 @@ info: |
|
|||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js, propertyHelper.js]
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
|
@ -35,31 +35,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
let counter = 0;
|
||||
var sample = new TA(1);
|
||||
|
||||
verifyConfigurable(sample, "0");
|
||||
Object.defineProperty(sample, "0", {
|
||||
get() {
|
||||
// If the slice operation reaches this code,
|
||||
// then it did not throw a TypeError exception
|
||||
// as a result of the detached buffer.
|
||||
//
|
||||
// Reaching this code is the equivalent to:
|
||||
//
|
||||
// If count > 0, then
|
||||
// If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
// Let srcName be the String value of O.[[TypedArrayName]].
|
||||
// Let srcType be the Element Type value in Table 62 for srcName.
|
||||
// Let targetName be the String value of A.[[TypedArrayName]].
|
||||
// Let targetType be the Element Type value in Table 62 for targetName.
|
||||
// If srcType is different from targetType, then
|
||||
// Let n be 0.
|
||||
// Repeat, while k < final,
|
||||
// Let Pk be ! ToString(k).
|
||||
// Let kValue be ! Get(O, Pk).
|
||||
//
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
sample.constructor = {};
|
||||
sample.constructor[Symbol.species] = function(count) {
|
||||
var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
|
||||
|
|
|
@ -13,7 +13,7 @@ info: |
|
|||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js, propertyHelper.js]
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
|
@ -21,31 +21,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
let counter = 0;
|
||||
var sample = new TA(1);
|
||||
|
||||
verifyConfigurable(sample, "0");
|
||||
Object.defineProperty(sample, "0", {
|
||||
get() {
|
||||
// If the slice operation reaches this code,
|
||||
// then it did not throw a TypeError exception
|
||||
// as a result of the detached buffer.
|
||||
//
|
||||
// Reaching this code is the equivalent to:
|
||||
//
|
||||
// If count > 0, then
|
||||
// If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
// Let srcName be the String value of O.[[TypedArrayName]].
|
||||
// Let srcType be the Element Type value in Table 62 for srcName.
|
||||
// Let targetName be the String value of A.[[TypedArrayName]].
|
||||
// Let targetType be the Element Type value in Table 62 for targetName.
|
||||
// If srcType is different from targetType, then
|
||||
// Let n be 0.
|
||||
// Repeat, while k < final,
|
||||
// Let Pk be ! ToString(k).
|
||||
// Let kValue be ! Get(O, Pk).
|
||||
//
|
||||
throw new Test262Error();
|
||||
}
|
||||
});
|
||||
|
||||
sample.constructor = {};
|
||||
sample.constructor[Symbol.species] = function(count) {
|
||||
var other = TA === Int8Array ? Int16Array : Int8Array;
|
||||
|
|
|
@ -22,15 +22,17 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
|
|||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([42, 43]);
|
||||
|
||||
var desc0 = Object.getOwnPropertyDescriptor(sample, 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]");
|
||||
verifyConfigurable(sample, "0", "index descriptor is configurable [0]");
|
||||
verifyProperty(sample, "0", {
|
||||
value: 42,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
var desc1 = Object.getOwnPropertyDescriptor(sample, 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]");
|
||||
verifyConfigurable(sample, "1", "index descriptor is configurable [1]");
|
||||
verifyProperty(sample, "1", {
|
||||
value: 43,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*---
|
||||
esid: sec-integer-indexed-exotic-objects-set-p-v-receiver
|
||||
description: >
|
||||
Returns false if 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)
|
||||
|
@ -33,5 +33,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
let OtherTA = other[TA.name];
|
||||
let sample = new OtherTA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.sameValue(sample[0] = 1n, false, '`sample[0] = 1n` is false');
|
||||
sample[0] = 1n;
|
||||
assert.sameValue(sample[0], undefined, '`sample[0]` is undefined');
|
||||
});
|
||||
|
|
|
@ -29,12 +29,18 @@ features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
|
|||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let sample = new TA([42n]);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
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');
|
||||
sample[0] = 1n;
|
||||
assert.sameValue(sample[0], undefined, '`sample[0] = 1n` is undefined');
|
||||
sample['1.1'] = 1n;
|
||||
assert.sameValue(sample['1.1'], undefined, '`sample["1.1"] = 1n` is undefined');
|
||||
sample['-0'] = 1n;
|
||||
assert.sameValue(sample['-0'], undefined, '`sample["-0"] = 1n` is undefined');
|
||||
sample['-1'] = 1n;
|
||||
assert.sameValue(sample['-1'], undefined, '`sample["-1"] = 1n` is undefined');
|
||||
sample['1'] = 1n;
|
||||
assert.sameValue(sample['1'], undefined, '`sample["1"] = 1n` is undefined');
|
||||
sample['2'] = 1n;
|
||||
assert.sameValue(sample['2'], undefined, '`sample["2"] = 1n` is undefined');
|
||||
|
||||
let obj = {
|
||||
valueOf() {
|
||||
|
|
|
@ -39,5 +39,5 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
});
|
||||
|
||||
assert.sameValue(result, false);
|
||||
assert.sameValue(ta[0], false);
|
||||
assert.sameValue(ta[0], undefined);
|
||||
});
|
||||
|
|
|
@ -33,5 +33,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
let OtherTA = other[TA.name];
|
||||
let sample = new OtherTA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.sameValue(sample[0] = 1, false, '`sample[0] = 1` is false');
|
||||
sample[0] = 1;
|
||||
assert.sameValue(sample[0], undefined, '`sample[0]` is undefined');
|
||||
});
|
||||
|
|
|
@ -29,12 +29,18 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
|
|||
testWithTypedArrayConstructors(function(TA) {
|
||||
let sample = new TA([42]);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.sameValue(sample[0] = 1, false, '`sample[0] = 1` is false');
|
||||
assert.sameValue(sample['1.1'] = 1, false, '`sample[\'1.1\'] = 1` is false');
|
||||
assert.sameValue(sample['-0'] = 1, false, '`sample[\'-0\'] = 1` is false');
|
||||
assert.sameValue(sample['-1'] = 1, false, '`sample[\'-1\'] = 1` is false');
|
||||
assert.sameValue(sample['1'] = 1, false, '`sample[\'1\'] = 1` is false');
|
||||
assert.sameValue(sample['2'] = 1, false, '`sample[\'2\'] = 1` is false');
|
||||
sample[0] = 1;
|
||||
assert.sameValue(sample[0], undefined, '`sample[0] = 1` is undefined');
|
||||
sample['1.1'] = 1;
|
||||
assert.sameValue(sample['1.1'], undefined, '`sample[\'1.1\'] = 1` is undefined');
|
||||
sample['-0'] = 1;
|
||||
assert.sameValue(sample['-0'], undefined, '`sample[\'-0\'] = 1` is undefined');
|
||||
sample['-1'] = 1;
|
||||
assert.sameValue(sample['-1'], undefined, '`sample[\'-1\'] = 1` is undefined');
|
||||
sample['1'] = 1;
|
||||
assert.sameValue(sample['1'], undefined, '`sample[\'1\'] = 1` is undefined');
|
||||
sample['2'] = 1;
|
||||
assert.sameValue(sample['2'], undefined, '`sample[\'2\'] = 1` is undefined');
|
||||
|
||||
let obj = {
|
||||
valueOf() {
|
||||
|
|
|
@ -39,5 +39,5 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
});
|
||||
|
||||
assert.sameValue(result, false);
|
||||
assert.sameValue(ta[0], false);
|
||||
assert.sameValue(ta[0], undefined);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue