mirror of https://github.com/tc39/test262.git
Add tests for typedArrays extensibility
Ref: https://github.com/tc39/test262/pull/536#issuecomment-200455389
This commit is contained in:
parent
c4086508db
commit
755b0d6117
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-buffer-byteoffset-length
|
||||||
|
description: >
|
||||||
|
The new typedArray instance from a buffer argument is extensible
|
||||||
|
info: >
|
||||||
|
22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
|
||||||
|
"%TypedArrayPrototype%").
|
||||||
|
...
|
||||||
|
|
||||||
|
22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
|
||||||
|
defaultProto [ , length ])
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
|
||||||
|
[[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
|
||||||
|
|
||||||
|
...
|
||||||
|
11. Set the [[Extensible]] internal slot of A to true.
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var buffer = new ArrayBuffer(8);
|
||||||
|
var sample = new TA(buffer);
|
||||||
|
|
||||||
|
assert(Object.isExtensible(sample));
|
||||||
|
});
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-length
|
||||||
|
description: >
|
||||||
|
The new typedArray instance from a length argument is extensible
|
||||||
|
info: >
|
||||||
|
22.2.4.2 TypedArray ( length )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with at
|
||||||
|
least one argument and the Type of the first argument is not Object.
|
||||||
|
|
||||||
|
...
|
||||||
|
8. Return ? AllocateTypedArray(constructorName, NewTarget,
|
||||||
|
%TypedArrayPrototype%, elementLength).
|
||||||
|
|
||||||
|
22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
|
||||||
|
defaultProto [ , length ])
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
|
||||||
|
[[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
|
||||||
|
|
||||||
|
...
|
||||||
|
11. Set the [[Extensible]] internal slot of A to true.
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var sample = new TA(4);
|
||||||
|
|
||||||
|
assert(Object.isExtensible(sample));
|
||||||
|
});
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray
|
||||||
|
description: >
|
||||||
|
The new typedArray instance is extensible
|
||||||
|
info: >
|
||||||
|
22.2.4.1 TypedArray( )
|
||||||
|
|
||||||
|
This description applies only if the TypedArray function is called with no
|
||||||
|
arguments.
|
||||||
|
|
||||||
|
...
|
||||||
|
3. Return ? AllocateTypedArray(constructorName, NewTarget,
|
||||||
|
%TypedArrayPrototype%, 0).
|
||||||
|
|
||||||
|
22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
|
||||||
|
defaultProto [ , length ])
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
|
||||||
|
[[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
|
||||||
|
|
||||||
|
...
|
||||||
|
11. Set the [[Extensible]] internal slot of A to true.
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var sample = new TA();
|
||||||
|
|
||||||
|
assert(Object.isExtensible(sample));
|
||||||
|
});
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-object
|
||||||
|
description: >
|
||||||
|
The new typedArray instance from an object argument is extensible
|
||||||
|
info: >
|
||||||
|
22.2.4.4 TypedArray ( object )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
|
||||||
|
"%TypedArrayPrototype%").
|
||||||
|
...
|
||||||
|
|
||||||
|
22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
|
||||||
|
defaultProto [ , length ])
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
|
||||||
|
[[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
|
||||||
|
|
||||||
|
...
|
||||||
|
11. Set the [[Extensible]] internal slot of A to true.
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
"0": 0,
|
||||||
|
"1": 1,
|
||||||
|
"2": 2,
|
||||||
|
length: 3
|
||||||
|
};
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var sample = new TA(obj);
|
||||||
|
|
||||||
|
assert(Object.isExtensible(sample));
|
||||||
|
});
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-typedarray-typedarray
|
||||||
|
description: >
|
||||||
|
The new typedArray instance from a typedArray argument is extensible
|
||||||
|
info: >
|
||||||
|
22.2.4.3 TypedArray ( typedArray )
|
||||||
|
|
||||||
|
...
|
||||||
|
4. Let O be ? AllocateTypedArray(constructorName, NewTarget,
|
||||||
|
"%TypedArrayPrototype%").
|
||||||
|
...
|
||||||
|
|
||||||
|
22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget,
|
||||||
|
defaultProto [ , length ])
|
||||||
|
|
||||||
|
...
|
||||||
|
2. Let obj be IntegerIndexedObjectCreate(proto, « [[ViewedArrayBuffer]],
|
||||||
|
[[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]] »).
|
||||||
|
...
|
||||||
|
|
||||||
|
9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList)
|
||||||
|
|
||||||
|
...
|
||||||
|
11. Set the [[Extensible]] internal slot of A to true.
|
||||||
|
...
|
||||||
|
includes: [testTypedArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var typedArraySample1 = new Int8Array();
|
||||||
|
var typedArraySample2 = new Int8Array();
|
||||||
|
Object.preventExtensions(typedArraySample2);
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var sample1 = new TA(typedArraySample1);
|
||||||
|
|
||||||
|
assert(Object.isExtensible(sample1), "new instance is extensible");
|
||||||
|
|
||||||
|
var sample2 = new TA(typedArraySample2);
|
||||||
|
assert(
|
||||||
|
Object.isExtensible(sample2),
|
||||||
|
"new instance does not inherit extensibility from typedarray argument"
|
||||||
|
);
|
||||||
|
});
|
Loading…
Reference in New Issue