mirror of https://github.com/tc39/test262.git
Cleanups
This commit is contained in:
parent
bf900a30b2
commit
59463a2dd7
|
@ -3,16 +3,31 @@
|
|||
/*---
|
||||
esid: sec-%typedarray%.prototype.slice
|
||||
description: >
|
||||
Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor (other targetType)
|
||||
Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor (other targetType)
|
||||
info: |
|
||||
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
|
||||
%TypedArray%.prototype.slice ( start, end )
|
||||
|
||||
...
|
||||
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]
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
|
||||
TypedArraySpeciesCreate ( exemplar, argumentList )
|
||||
|
||||
Let result be ? TypedArrayCreate(constructor, argumentList).
|
||||
|
||||
TypedArrayCreate ( constructor, argumentList )
|
||||
|
||||
Let newTypedArray be ? Construct(constructor, argumentList).
|
||||
Perform ? ValidateTypedArray(newTypedArray).
|
||||
|
||||
ValidateTypedArray ( O )
|
||||
The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
|
||||
|
||||
Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
|
||||
Assert: O has a [[ViewedArrayBuffer]] internal slot.
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js, propertyHelper.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
|
@ -20,11 +35,35 @@ 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;
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
return new other(count);
|
||||
};
|
||||
|
|
|
@ -3,15 +3,30 @@
|
|||
/*---
|
||||
esid: sec-%typedarray%.prototype.slice
|
||||
description: >
|
||||
Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor.
|
||||
Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor.
|
||||
info: |
|
||||
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
|
||||
%TypedArray%.prototype.slice ( start, end )
|
||||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
|
||||
TypedArraySpeciesCreate ( exemplar, argumentList )
|
||||
|
||||
Let result be ? TypedArrayCreate(constructor, argumentList).
|
||||
|
||||
TypedArrayCreate ( constructor, argumentList )
|
||||
|
||||
Let newTypedArray be ? Construct(constructor, argumentList).
|
||||
Perform ? ValidateTypedArray(newTypedArray).
|
||||
|
||||
ValidateTypedArray ( O )
|
||||
The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
|
||||
|
||||
Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
|
||||
Assert: O has a [[ViewedArrayBuffer]] internal slot.
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
...
|
||||
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: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
@ -23,7 +38,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
sample.constructor = {};
|
||||
sample.constructor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
return new TA(count);
|
||||
};
|
||||
|
|
|
@ -2,15 +2,31 @@
|
|||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-%typedarray%.prototype.slice
|
||||
description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached.
|
||||
description: >
|
||||
Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor.
|
||||
info: |
|
||||
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
|
||||
%TypedArray%.prototype.slice ( start, end )
|
||||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
|
||||
TypedArraySpeciesCreate ( exemplar, argumentList )
|
||||
|
||||
Let result be ? TypedArrayCreate(constructor, argumentList).
|
||||
|
||||
TypedArrayCreate ( constructor, argumentList )
|
||||
|
||||
Let newTypedArray be ? Construct(constructor, argumentList).
|
||||
Perform ? ValidateTypedArray(newTypedArray).
|
||||
|
||||
ValidateTypedArray ( O )
|
||||
The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
|
||||
|
||||
Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
|
||||
Assert: O has a [[ViewedArrayBuffer]] internal slot.
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
...
|
||||
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: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
|
||||
---*/
|
||||
|
|
|
@ -4,13 +4,27 @@
|
|||
esid: sec-%typedarray%.prototype.slice
|
||||
description: Throws a TypeError if buffer of object created by custom constructor is detached.
|
||||
info: |
|
||||
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
|
||||
%TypedArray%.prototype.slice ( start, end )
|
||||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
Return A.
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
|
||||
TypedArraySpeciesCreate ( exemplar, argumentList )
|
||||
|
||||
Let result be ? TypedArrayCreate(constructor, argumentList).
|
||||
|
||||
TypedArrayCreate ( constructor, argumentList )
|
||||
|
||||
Let newTypedArray be ? Construct(constructor, argumentList).
|
||||
Perform ? ValidateTypedArray(newTypedArray).
|
||||
|
||||
ValidateTypedArray ( O )
|
||||
The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
|
||||
|
||||
Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
|
||||
Assert: O has a [[ViewedArrayBuffer]] internal slot.
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
|
||||
|
@ -24,7 +38,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
sample.constructor[Symbol.species] = function(count) {
|
||||
let other = new TA(count);
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(other.buffer);
|
||||
return other;
|
||||
};
|
||||
|
|
|
@ -10,8 +10,7 @@ info: |
|
|||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
...
|
||||
Return A
|
||||
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
|
@ -24,7 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
let ctor = {};
|
||||
ctor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 0);
|
||||
Other = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
other = new Other(count);
|
||||
|
|
|
@ -10,8 +10,7 @@ info: |
|
|||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
...
|
||||
Return A
|
||||
includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray]
|
||||
|
@ -23,7 +22,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
let ctor = {};
|
||||
ctor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 0, 'The value of `count` is 0');
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
other = new TA(count);
|
||||
return other;
|
||||
|
|
|
@ -13,7 +13,7 @@ info: |
|
|||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js, propertyHelper.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
|
||||
---*/
|
||||
|
||||
|
@ -21,11 +21,35 @@ 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;
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
return new other(count);
|
||||
};
|
||||
|
|
|
@ -22,7 +22,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
sample.constructor = {};
|
||||
sample.constructor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
return new TA(count);
|
||||
};
|
||||
|
|
|
@ -4,13 +4,27 @@
|
|||
esid: sec-%typedarray%.prototype.slice
|
||||
description: Throws a TypeError if buffer of object created by custom constructor is detached.
|
||||
info: |
|
||||
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
|
||||
%TypedArray%.prototype.slice ( start, end )
|
||||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
Return A.
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
|
||||
TypedArraySpeciesCreate ( exemplar, argumentList )
|
||||
|
||||
Let result be ? TypedArrayCreate(constructor, argumentList).
|
||||
|
||||
TypedArrayCreate ( constructor, argumentList )
|
||||
|
||||
Let newTypedArray be ? Construct(constructor, argumentList).
|
||||
Perform ? ValidateTypedArray(newTypedArray).
|
||||
|
||||
ValidateTypedArray ( O )
|
||||
The abstract operation ValidateTypedArray takes argument O. It performs the following steps when called:
|
||||
|
||||
Perform ? RequireInternalSlot(O, [[TypedArrayName]]).
|
||||
Assert: O has a [[ViewedArrayBuffer]] internal slot.
|
||||
Let buffer be O.[[ViewedArrayBuffer]].
|
||||
If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray]
|
||||
|
@ -24,7 +38,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
sample.constructor[Symbol.species] = function(count) {
|
||||
let other = new TA(count);
|
||||
counter++;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
$DETACHBUFFER(other.buffer);
|
||||
return other;
|
||||
};
|
||||
|
|
|
@ -10,8 +10,7 @@ info: |
|
|||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
...
|
||||
Return A
|
||||
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
|
@ -24,7 +23,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
let ctor = {};
|
||||
ctor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 0);
|
||||
Other = TA === Int16Array ? Int8Array : Int16Array;
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
other = new Other(count);
|
||||
|
|
|
@ -10,7 +10,6 @@ info: |
|
|||
|
||||
Let A be ? TypedArraySpeciesCreate(O, « count »).
|
||||
If count > 0, then
|
||||
If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception.
|
||||
...
|
||||
Return A
|
||||
includes: [testTypedArray.js, detachArrayBuffer.js]
|
||||
|
@ -23,7 +22,6 @@ testWithTypedArrayConstructors(function(TA) {
|
|||
let ctor = {};
|
||||
ctor[Symbol.species] = function(count) {
|
||||
counter++;
|
||||
assert.sameValue(count, 0);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
other = new TA(count);
|
||||
return other;
|
||||
|
|
|
@ -43,6 +43,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, '0', desc),
|
||||
false,
|
||||
'Reflect.defineProperty( sample, "0", {value: 0n, configurable: true, enumerable: true, writable: true} ) must return false'
|
||||
'Reflect.defineProperty(sample, "0", {value: 0n, configurable: true, enumerable: true, writable: true} ) must return false'
|
||||
);
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
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');
|
||||
}), true, 'Reflect.defineProperty(sample, "0", {value: 8n, configurable: true, enumerable: true, writable: true}) must return true');
|
||||
|
||||
assert.sameValue(sample[0], 8n, 'The value of sample[0] is 8n');
|
||||
var desc = Object.getOwnPropertyDescriptor(sample, '0');
|
||||
|
|
|
@ -34,9 +34,9 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
|||
var sample = new TA(42);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
let count = 0;
|
||||
let counter = 0;
|
||||
for (var key in sample) {
|
||||
count++;
|
||||
counter++;
|
||||
}
|
||||
assert.sameValue(count, 0, 'The value of `count` is 0');
|
||||
assert.sameValue(counter, 0, 'The value of `counter` is 0');
|
||||
});
|
||||
|
|
|
@ -25,22 +25,22 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js]
|
|||
features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray]
|
||||
---*/
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
let count = 0;
|
||||
let counter = 0;
|
||||
|
||||
let n = {
|
||||
valueOf() {
|
||||
count++;
|
||||
counter++;
|
||||
return 9n;
|
||||
}
|
||||
};
|
||||
|
||||
assert.sameValue(count, 0, 'The value of `count` is 0');
|
||||
assert.sameValue(counter, 0, 'The value of `counter` is 0');
|
||||
let ta = new TA([n]);
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
assert.sameValue(counter, 1, 'The value of `counter` is 1');
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
|
||||
with (ta) {
|
||||
Infinity;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
assert.sameValue(counter, 1, 'The value of `counter` is 1');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,24 +27,24 @@ features: [align-detached-buffer-semantics-with-web-reality, TypedArray]
|
|||
---*/
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
let count = 0;
|
||||
let counter = 0;
|
||||
let n = {
|
||||
valueOf() {
|
||||
count++;
|
||||
counter++;
|
||||
return 9;
|
||||
}
|
||||
};
|
||||
|
||||
assert.sameValue(count, 0, 'The value of `count` is 0');
|
||||
assert.sameValue(counter, 0, 'The value of `counter` is 0');
|
||||
|
||||
let ta = new TA([n]);
|
||||
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
assert.sameValue(counter, 1, 'The value of `counter` is 1');
|
||||
|
||||
$DETACHBUFFER(ta.buffer);
|
||||
|
||||
with (ta) {
|
||||
Infinity;
|
||||
assert.sameValue(count, 1, 'The value of `count` is 1');
|
||||
assert.sameValue(counter, 1, 'The value of `counter` is 1');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue