From 7d715a4ef126400448000f5cba6309d38d43b116 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Thu, 21 Jan 2016 17:07:37 -0500 Subject: [PATCH 1/7] Revalidate basic call tests for ES2016 %TypedArray% constructor --- .../invoked-as-ctor-with-arguments.js | 30 --------- test/built-ins/TypedArray/invoked-as-ctor.js | 17 ----- test/built-ins/TypedArray/invoked-as-func.js | 16 ----- test/built-ins/TypedArray/invoked.js | 65 +++++++++++++++++++ 4 files changed, 65 insertions(+), 63 deletions(-) delete mode 100644 test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js delete mode 100644 test/built-ins/TypedArray/invoked-as-ctor.js delete mode 100644 test/built-ins/TypedArray/invoked-as-func.js create mode 100644 test/built-ins/TypedArray/invoked.js diff --git a/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js b/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js deleted file mode 100644 index 6bc266f56b..0000000000 --- a/test/built-ins/TypedArray/invoked-as-ctor-with-arguments.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es7id: pending -description: TypedArray(length) cannot be direclty invoked as a constructor -info: > - 22.2.1.1 %TypedArray%()# - - 1. If NewTarget is undefined, throw a TypeError exception. - 2. Let here be the active function object. - 3. If SameValue(NewTarget, here) is true, throw a TypeError exception. - ... - - Note: there's a breaking change from ES2015's 22.2.1.2 step 7 where calling - the %TypedArray% constructor with a floating number as the argument throws a - RangeError exception before checking `SameValue(NewTarget, here)`. -includes: [testTypedArray.js] ----*/ - -assert.throws(TypeError, function() { - new TypedArray(1); -}); - -assert.throws(TypeError, function() { - new TypedArray({}); -}); - -assert.throws(TypeError, function() { - new TypedArray(1.1); -}); diff --git a/test/built-ins/TypedArray/invoked-as-ctor.js b/test/built-ins/TypedArray/invoked-as-ctor.js deleted file mode 100644 index 668a963404..0000000000 --- a/test/built-ins/TypedArray/invoked-as-ctor.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 22.2.1.2.1 -description: TypedArray cannot be invoked as a constructor -info: > - 22.2.1.2.1 Runtime Semantics: AllocateTypedArray (newTarget, length ) - - ... - 2. If SameValue(%TypedArray%, newTarget) is true, throw a TypeError exception. - ... -includes: [testTypedArray.js] ----*/ - -assert.throws(TypeError, function() { - new TypedArray(); -}); diff --git a/test/built-ins/TypedArray/invoked-as-func.js b/test/built-ins/TypedArray/invoked-as-func.js deleted file mode 100644 index a7a5d990f2..0000000000 --- a/test/built-ins/TypedArray/invoked-as-func.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2016 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 22.2.1.1 -description: If NewTarget is undefined, throw a TypeError exception. -info: > - 22.2.1.1 %TypedArray% ( ) - - 1. If NewTarget is undefined, throw a TypeError exception. - ... -includes: [testTypedArray.js] ----*/ - -assert.throws(TypeError, function() { - TypedArray(); -}); diff --git a/test/built-ins/TypedArray/invoked.js b/test/built-ins/TypedArray/invoked.js new file mode 100644 index 0000000000..e208677c60 --- /dev/null +++ b/test/built-ins/TypedArray/invoked.js @@ -0,0 +1,65 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es7id: pending +description: Throw a TypeError exception if directly invoked. +info: > + 22.2.1.1 %TypedArray% ( ) + + 1. Throw a TypeError Exception + ... + + Note: ES2016 replaces all the references for the %TypedArray% constructor to a + single chapter covering all arguments cases. +includes: [testTypedArray.js] +---*/ + +assert.throws(TypeError, function() { + TypedArray(); +}); + +assert.throws(TypeError, function() { + new TypedArray(); +}); + +assert.throws(TypeError, function() { + TypedArray(1); +}); + +assert.throws(TypeError, function() { + new TypedArray(1); +}); + +assert.throws(TypeError, function() { + TypedArray(1.1); +}); + +assert.throws(TypeError, function() { + new TypedArray(1.1); +}); + +assert.throws(TypeError, function() { + TypedArray({}); +}); + +assert.throws(TypeError, function() { + new TypedArray({}); +}); + +var typedArray = new Int8Array(4); +assert.throws(TypeError, function() { + TypedArray(typedArray); +}); + +assert.throws(TypeError, function() { + new TypedArray(typedArray); +}); + +var buffer = new ArrayBuffer(4); +assert.throws(TypeError, function() { + TypedArray(buffer); +}); + +assert.throws(TypeError, function() { + new TypedArray(buffer); +}); From 4bdd808d048dec99d4f03067ce7d504f7bfc39be Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Fri, 22 Jan 2016 15:00:44 -0500 Subject: [PATCH 2/7] Update %TypedArray% function length --- test/built-ins/TypedArray/length.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/built-ins/TypedArray/length.js b/test/built-ins/TypedArray/length.js index b198205b63..ea475c5dd4 100644 --- a/test/built-ins/TypedArray/length.js +++ b/test/built-ins/TypedArray/length.js @@ -1,23 +1,22 @@ // Copyright (C) 2016 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.2.2 +es7id: pending description: > - TypedArray has a "length" property whose value is 3. + TypedArray has a "length" property whose value is 0. info: > - 22.2.2 Properties of the %TypedArray% Intrinsic Object + 22.2.1.1 %TypedArray% () - Besides a length property whose value is 3 and a name property whose value is - "TypedArray", %TypedArray% has the following properties: + The length property of the %TypedArray% constructor function is 0. ... - ES6 section 17: Unless otherwise specified, the length property of a built-in + ES7 section 17: Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js, testTypedArray.js] ---*/ -assert.sameValue(TypedArray.length, 3); +assert.sameValue(TypedArray.length, 0); verifyNotEnumerable(TypedArray, 'length'); verifyNotWritable(TypedArray, 'length'); From f8a4229bfd64b8e8de7fc5b00b19b61cb8494e89 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Fri, 22 Jan 2016 11:36:26 -0500 Subject: [PATCH 3/7] Add tests for TypedArrays constructors --- .../Float32Array/undefined-newtarget.js | 32 ------- .../Float64Array/undefined-newtarget.js | 32 ------- .../Int16Array/undefined-newtarget.js | 32 ------- .../Int32Array/undefined-newtarget.js | 32 ------- .../Int8Array/undefined-newtarget.js | 32 ------- .../Uint16Array/undefined-newtarget.js | 32 ------- .../Uint32Array/undefined-newtarget.js | 32 ------- .../Uint8Array/undefined-newtarget.js | 32 ------- .../Uint8ClampedArray/undefined-newtarget.js | 32 ------- ...eoffset-throws-from-modulo-element-size.js | 36 +++++++ ...-argument-byteoffset-is-negative-throws.js | 30 ++++++ ...er-argument-byteoffset-is-symbol-throws.js | 28 ++++++ ...eoffset-throws-from-modulo-element-size.js | 31 ++++++ ...er-argument-byteoffset-to-number-throws.js | 31 ++++++ ...ffer-argument-defined-length-and-offset.js | 35 +++++++ .../buffer-argument-defined-length.js | 31 ++++++ ...buffer-argument-defined-negative-length.js | 41 ++++++++ .../buffer-argument-defined-offset.js | 29 ++++++ ...buffer-argument-excessive-length-throws.js | 29 ++++++ ...buffer-argument-excessive-offset-throws.js | 33 +++++++ .../buffer-argument-is-referenced.js | 29 ++++++ ...ument-returns-abrupt-from-length-symbol.js | 29 ++++++ ...fer-argument-returns-abrupt-from-length.js | 32 +++++++ .../buffer-single-argument-single.js | 30 ++++++ .../called-with-length-return-object.js | 35 +++++++ .../called-with-no-arguments-return-object.js | 31 ++++++ ...led-with-typedarray-return-new-instance.js | 31 ++++++ ...ith-buffer-argument-proto-is-not-object.js | 45 +++++++++ ...pe-with-buffer-argument-proto-is-object.js | 47 ++++++++++ ...ype-with-buffer-argument-returns-abrupt.js | 47 ++++++++++ ...ith-length-argument-proto-is-not-object.js | 41 ++++++++ ...pe-with-length-argument-proto-is-object.js | 43 +++++++++ ...ype-with-length-argument-returns-abrupt.js | 43 +++++++++ ...e-with-no-arguments-proto-is-not-object.js | 41 ++++++++ ...otype-with-no-arguments-proto-is-object.js | 43 +++++++++ ...totype-with-no-arguments-returns-abrupt.js | 43 +++++++++ ...ith-object-argument-proto-is-not-object.js | 45 +++++++++ ...pe-with-object-argument-proto-is-object.js | 46 +++++++++ ...ype-with-object-argument-returns-abrupt.js | 48 ++++++++++ ...typedarray-argument-proto-is-not-object.js | 45 +++++++++ ...ith-typedarray-argument-proto-is-object.js | 47 ++++++++++ ...with-typedarray-argument-returns-abrupt.js | 47 ++++++++++ .../length-is-float-throws-rangeerror.js | 26 +++++ .../length-is-infinity-throws-rangeerror.js | 26 +++++ .../length-is-nan-throws-rangeerror.js | 26 +++++ ...th-is-negative-number-throws-rangeerror.js | 26 +++++ ...not-valid-buffer-size-throws-rangeerror.js | 53 +++++++++++ .../TypedArrays/length-is-symbol-throws.js | 26 +++++ .../TypedArrays/length-is-undefined-throws.js | 23 +++++ .../object-argument-as-array-returns.js | 26 +++++ ...-argument-as-generator-iterable-returns.js | 28 ++++++ .../object-argument-iterating-throws.js | 30 ++++++ ...t-argument-iterator-not-callable-throws.js | 39 ++++++++ .../object-argument-iterator-throws.js | 34 +++++++ ...object-argument-length-excessive-throws.js | 30 ++++++ ...object-argument-length-is-symbol-throws.js | 30 ++++++ .../object-argument-length-throws.js | 33 +++++++ .../TypedArrays/object-argument-returns.js | 32 +++++++ .../object-argument-throws-from-property.js | 37 ++++++++ ...object-argument-throws-setting-property.js | 37 ++++++++ ...argument-throws-setting-symbol-property.js | 34 +++++++ ...tor-argument-buffer-ctor-species-custom.js | 52 ++++++++++ ...r-argument-buffer-ctor-species-not-ctor.js | 45 +++++++++ ...-ctor-argument-buffer-ctor-species-null.js | 46 +++++++++ ...nt-buffer-ctor-species-prototype-abrupt.js | 59 ++++++++++++ ...-argument-buffer-ctor-species-undefined.js | 45 +++++++++ ...returns-abrupt-from-constructor-species.js | 45 +++++++++ ...r-returns-abrupt-from-constructor-value.js | 90 ++++++++++++++++++ ...fer-returns-abrupt-from-get-constructor.js | 41 ++++++++ ...ay-ctor-argument-returns-new-typedarray.js | 27 ++++++ ...tor-argument-buffer-ctor-species-custom.js | 60 ++++++++++++ ...r-argument-buffer-ctor-species-not-ctor.js | 49 ++++++++++ ...-ctor-argument-buffer-ctor-species-null.js | 49 ++++++++++ ...nt-buffer-ctor-species-prototype-abrupt.js | 62 ++++++++++++ ...-argument-buffer-ctor-species-undefined.js | 49 ++++++++++ ...returns-abrupt-from-constructor-species.js | 49 ++++++++++ ...r-returns-abrupt-from-constructor-value.js | 94 +++++++++++++++++++ ...fer-returns-abrupt-from-get-constructor.js | 45 +++++++++ ...-argument-returns-new-cloned-typedarray.js | 29 ++++++ ...ined-newtarget-invoked-with-arraybuffer.js | 25 +++++ ...undefined-newtarget-invoked-with-length.js | 50 ++++++++++ ...ned-newtarget-invoked-with-no-arguments.js | 22 +++++ ...undefined-newtarget-invoked-with-object.js | 29 ++++++ ...fined-newtarget-invoked-with-typedarray.js | 26 +++++ 84 files changed, 2926 insertions(+), 288 deletions(-) delete mode 100755 test/built-ins/TypedArrays/Float32Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Float64Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Int16Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Int32Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Int8Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Uint16Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Uint32Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Uint8Array/undefined-newtarget.js delete mode 100755 test/built-ins/TypedArrays/Uint8ClampedArray/undefined-newtarget.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-defined-length.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-defined-offset.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-is-referenced.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js create mode 100644 test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js create mode 100644 test/built-ins/TypedArrays/buffer-single-argument-single.js create mode 100644 test/built-ins/TypedArrays/called-with-length-return-object.js create mode 100644 test/built-ins/TypedArrays/called-with-no-arguments-return-object.js create mode 100644 test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js create mode 100644 test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js create mode 100644 test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js create mode 100644 test/built-ins/TypedArrays/length-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/length-is-undefined-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-as-array-returns.js create mode 100644 test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js create mode 100644 test/built-ins/TypedArrays/object-argument-iterating-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-iterator-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-length-excessive-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-length-throws.js create mode 100644 test/built-ins/TypedArrays/object-argument-returns.js create mode 100644 test/built-ins/TypedArrays/object-argument-throws-from-property.js create mode 100644 test/built-ins/TypedArrays/object-argument-throws-setting-property.js create mode 100644 test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js create mode 100644 test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js create mode 100644 test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js create mode 100644 test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js create mode 100644 test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js create mode 100755 test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js create mode 100644 test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js create mode 100644 test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js diff --git a/test/built-ins/TypedArrays/Float32Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Float32Array/undefined-newtarget.js deleted file mode 100755 index 35478521be..0000000000 --- a/test/built-ins/TypedArrays/Float32Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Float32Array(); -}, "Float32Array()"); - -assert.throws(TypeError, function() { - Float32Array(0); -}, "Float32Array(0)"); - -assert.throws(TypeError, function() { - Float32Array(new Float32Array(1)); -}, "Float32Array(float32Array)"); - -assert.throws(TypeError, function() { - Float32Array([]); -}, "Float32Array(array)"); - -assert.throws(TypeError, function() { - Float32Array(new ArrayBuffer(8)); -}, "Float32Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Float64Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Float64Array/undefined-newtarget.js deleted file mode 100755 index 32ed0fb33b..0000000000 --- a/test/built-ins/TypedArrays/Float64Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Float64Array(); -}, "Float64Array()"); - -assert.throws(TypeError, function() { - Float64Array(0); -}, "Float64Array(0)"); - -assert.throws(TypeError, function() { - Float64Array(new Float64Array(1)); -}, "Float64Array(float64Array)"); - -assert.throws(TypeError, function() { - Float64Array([]); -}, "Float64Array(array)"); - -assert.throws(TypeError, function() { - Float64Array(new ArrayBuffer(8)); -}, "Float64Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Int16Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Int16Array/undefined-newtarget.js deleted file mode 100755 index 664fc5ba0a..0000000000 --- a/test/built-ins/TypedArrays/Int16Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Int16Array(); -}, "Int16Array()"); - -assert.throws(TypeError, function() { - Int16Array(0); -}, "Int16Array(0)"); - -assert.throws(TypeError, function() { - Int16Array(new Int16Array(1)); -}, "Int16Array(int16Array)"); - -assert.throws(TypeError, function() { - Int16Array([]); -}, "Int16Array(array)"); - -assert.throws(TypeError, function() { - Int16Array(new ArrayBuffer(8)); -}, "Int16Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Int32Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Int32Array/undefined-newtarget.js deleted file mode 100755 index 6f42e423c4..0000000000 --- a/test/built-ins/TypedArrays/Int32Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Int32Array(); -}, "Int32Array()"); - -assert.throws(TypeError, function() { - Int32Array(0); -}, "Int32Array(0)"); - -assert.throws(TypeError, function() { - Int32Array(new Int32Array(1)); -}, "Int32Array(int32Array)"); - -assert.throws(TypeError, function() { - Int32Array([]); -}, "Int32Array(array)"); - -assert.throws(TypeError, function() { - Int32Array(new ArrayBuffer(8)); -}, "Int32Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Int8Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Int8Array/undefined-newtarget.js deleted file mode 100755 index 4a3f8dc17e..0000000000 --- a/test/built-ins/TypedArrays/Int8Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Int8Array(); -}, "Int8Array()"); - -assert.throws(TypeError, function() { - Int8Array(0); -}, "Int8Array(0)"); - -assert.throws(TypeError, function() { - Int8Array(new Int8Array(1)); -}, "Int8Array(int8Array)"); - -assert.throws(TypeError, function() { - Int8Array([]); -}, "Int8Array(array)"); - -assert.throws(TypeError, function() { - Int8Array(new ArrayBuffer(8)); -}, "Int8Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Uint16Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Uint16Array/undefined-newtarget.js deleted file mode 100755 index fbbd92d4dd..0000000000 --- a/test/built-ins/TypedArrays/Uint16Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Uint16Array(); -}, "Uint16Array()"); - -assert.throws(TypeError, function() { - Uint16Array(0); -}, "Uint16Array(0)"); - -assert.throws(TypeError, function() { - Uint16Array(new Uint16Array(1)); -}, "Uint16Array(uint16Array)"); - -assert.throws(TypeError, function() { - Uint16Array([]); -}, "Uint16Array(array)"); - -assert.throws(TypeError, function() { - Uint16Array(new ArrayBuffer(8)); -}, "Uint16Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Uint32Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Uint32Array/undefined-newtarget.js deleted file mode 100755 index d74e02736a..0000000000 --- a/test/built-ins/TypedArrays/Uint32Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Uint32Array(); -}, "Uint32Array()"); - -assert.throws(TypeError, function() { - Uint32Array(0); -}, "Uint32Array(0)"); - -assert.throws(TypeError, function() { - Uint32Array(new Uint32Array(1)); -}, "Uint32Array(uint32Array)"); - -assert.throws(TypeError, function() { - Uint32Array([]); -}, "Uint32Array(array)"); - -assert.throws(TypeError, function() { - Uint32Array(new ArrayBuffer(8)); -}, "Uint32Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Uint8Array/undefined-newtarget.js b/test/built-ins/TypedArrays/Uint8Array/undefined-newtarget.js deleted file mode 100755 index d592176d6f..0000000000 --- a/test/built-ins/TypedArrays/Uint8Array/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Uint8Array(); -}, "Uint8Array()"); - -assert.throws(TypeError, function() { - Uint8Array(0); -}, "Uint8Array(0)"); - -assert.throws(TypeError, function() { - Uint8Array(new Uint8Array(1)); -}, "Uint8Array(uint8Array)"); - -assert.throws(TypeError, function() { - Uint8Array([]); -}, "Uint8Array(array)"); - -assert.throws(TypeError, function() { - Uint8Array(new ArrayBuffer(8)); -}, "Uint8Array(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/Uint8ClampedArray/undefined-newtarget.js b/test/built-ins/TypedArrays/Uint8ClampedArray/undefined-newtarget.js deleted file mode 100755 index 63c1dbd767..0000000000 --- a/test/built-ins/TypedArrays/Uint8ClampedArray/undefined-newtarget.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es6id: 22.2.4.1 -description: > - Throws a TypeError if NewTarget is undefined. -info: > - TypedArray( ... argumentsList) - - 1. If NewTarget is undefined, throw a TypeError exception. ----*/ - -assert.throws(TypeError, function() { - Uint8ClampedArray(); -}, "Uint8ClampedArray()"); - -assert.throws(TypeError, function() { - Uint8ClampedArray(0); -}, "Uint8ClampedArray(0)"); - -assert.throws(TypeError, function() { - Uint8ClampedArray(new Uint8ClampedArray(1)); -}, "Uint8ClampedArray(uint8clampedArray)"); - -assert.throws(TypeError, function() { - Uint8ClampedArray([]); -}, "Uint8ClampedArray(array)"); - -assert.throws(TypeError, function() { - Uint8ClampedArray(new ArrayBuffer(8)); -}, "Uint8ClampedArray(arrayBuffer)"); diff --git a/test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js new file mode 100644 index 0000000000..5bf697b6ef --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js @@ -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. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength modulo elementSize ≠ 0 +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 13. If length is undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(1); + +testWithTypedArrayConstructors(function(TA) { + if (TA.BYTES_PER_ELEMENT === 1) { + // Impossible to trigger this step here. + return; + } + + assert.throws(RangeError, function() { + new TA(buffer); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 0, undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js new file mode 100644 index 0000000000..a566ad0612 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) is < 0 +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + 8. If offset < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, -1); + }); + assert.throws(RangeError, function() { + new TA(buffer, -Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js new file mode 100644 index 0000000000..0b11674b60 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset as a symbol +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var byteOffset = Symbol("1"); +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js new file mode 100644 index 0000000000..6bab1c7e1e --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a RangeError if ToInteger(byteOffset) modulo elementSize is not 0 +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 9. If offset modulo elementSize ≠ 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + if (TA.BYTES_PER_ELEMENT === 1) { + // Impossible to trigger this step here. + return; + } + + assert.throws(RangeError, function() { + new TA(buffer, 7); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js new file mode 100644 index 0000000000..f04bdce84c --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return abrupt from parsing integer value from byteOffset +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 7. Let offset be ? ToInteger(byteOffset). + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); +var byteOffset = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, byteOffset); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js b/test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js new file mode 100644 index 0000000000..e305ab731e --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return new typedArray from defined length and offset +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var offset = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(3 * offset); + + var ta1 = new TA(buffer, offset, 2); + assert.sameValue(ta1.length, 2, "ta1.length"); + assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); + assert.sameValue( + Object.getPrototypeOf(ta1), TA.prototype, + "Object.getPrototypeOf(ta1)" + ); + + var ta2 = new TA(buffer, offset, 0); + assert.sameValue(ta2.length, 0, "ta2.length"); + assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); + assert.sameValue( + Object.getPrototypeOf(ta2), TA.prototype, + "Object.getPrototypeOf(ta2)" + ); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-length.js b/test/built-ins/TypedArrays/buffer-argument-defined-length.js new file mode 100644 index 0000000000..125c224c9b --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-defined-length.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return new typedArray from defined length +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var length = 4; + var buffer = new ArrayBuffer(bpe * length * 4); + + var ta1 = new TA(buffer, 0, length); + assert.sameValue(ta1.length, length); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0, 0); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js b/test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js new file mode 100644 index 0000000000..8bb321f3da --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return new typedArray from negative defined length +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var length = 4; + var buffer = new ArrayBuffer(bpe * length * 4); + + var ta1 = new TA(buffer, 0, -1); + assert.sameValue(ta1.length, 0); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0, -Infinity); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); + + var ta3 = new TA(buffer, 8, -1); + assert.sameValue(ta3.length, 0); + assert.sameValue(ta3.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta3), TA.prototype); + + var ta4 = new TA(buffer, 8, -Infinity); + assert.sameValue(ta4.length, 0); + assert.sameValue(ta4.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta4), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-offset.js b/test/built-ins/TypedArrays/buffer-argument-defined-offset.js new file mode 100644 index 0000000000..bc7e49fc68 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-defined-offset.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return new typedArray from defined offset +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe * 4); + + var ta1 = new TA(buffer, bpe * 2); + assert.sameValue(ta1.length, 2); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var ta2 = new TA(buffer, 0); + assert.sameValue(ta2.length, 4); + assert.sameValue(ta2.buffer, buffer); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js b/test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js new file mode 100644 index 0000000000..439b550879 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + If offset + newByteLength > bufferByteLength, throw a RangeError exception. +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + b. Let newByteLength be newLength × elementSize. + c. If offset+newByteLength > bufferByteLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 0, 16); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js b/test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js new file mode 100644 index 0000000000..9270c51ebc --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a RangeError if bufferByteLength - ToInteger(byteOffset) < 0 +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 13. If length is undefined, then + a. If bufferByteLength modulo elementSize ≠ 0, throw a RangeError exception. + b. Let newByteLength be bufferByteLength - offset. + c. If newByteLength < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(buffer, 16); + }); + + assert.throws(RangeError, function() { + new TA(buffer, 16, undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-is-referenced.js b/test/built-ins/TypedArrays/buffer-argument-is-referenced.js new file mode 100644 index 0000000000..ef331db521 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-is-referenced.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Reuse buffer argument instead of making a new clone +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 15. Set O's [[ViewedArrayBuffer]] internal slot to buffer. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer = new ArrayBuffer(bpe * 4); + + var ta1 = new TA(buffer); + var ta2 = new TA(buffer); + + assert.sameValue(ta1.buffer, ta2.buffer); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js b/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js new file mode 100644 index 0000000000..8b08b8b5ce --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a TypeError if length is a Symbol +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var buffer = new ArrayBuffer(8); +var length = Symbol("1"); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(buffer, 0, length); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js b/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js new file mode 100644 index 0000000000..76a5a160b5 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Returns abrupt from ToLength(length) +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 14. Else, + a. Let newLength be ? ToLength(length). + ... +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); +var length = { + valueOf() { + throw new Test262Error(); + } +} + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(buffer, 0, length); + }); +}); diff --git a/test/built-ins/TypedArrays/buffer-single-argument-single.js b/test/built-ins/TypedArrays/buffer-single-argument-single.js new file mode 100644 index 0000000000..62892b4c36 --- /dev/null +++ b/test/built-ins/TypedArrays/buffer-single-argument-single.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return new typedArray from undefined defined offset +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + + var buffer1 = new ArrayBuffer(bpe * 4); + var ta1 = new TA(buffer1); + assert.sameValue(ta1.length, 4); + assert.sameValue(ta1.buffer, buffer1); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); + + var buffer2 = new ArrayBuffer(0); + var ta2 = new TA(buffer2); + assert.sameValue(ta2.length, 0); + assert.sameValue(ta2.buffer, buffer2); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/called-with-length-return-object.js b/test/built-ins/TypedArrays/called-with-length-return-object.js new file mode 100644 index 0000000000..669c113550 --- /dev/null +++ b/test/built-ins/TypedArrays/called-with-length-return-object.js @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Return a TypedArray object +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 ]) + + ... + 7. Return obj +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(4); + var bytesPerElement = TA.BYTES_PER_ELEMENT; + var length = typedArray.length; + + assert.sameValue(length, 4, "length"); + assert.sameValue( + Object.getPrototypeOf(typedArray), TA.prototype, + "Object.getPrototypeOf(typedArray)" + ); +}); diff --git a/test/built-ins/TypedArrays/called-with-no-arguments-return-object.js b/test/built-ins/TypedArrays/called-with-no-arguments-return-object.js new file mode 100644 index 0000000000..d9e7d91318 --- /dev/null +++ b/test/built-ins/TypedArrays/called-with-no-arguments-return-object.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray +description: > + Return a TypedArray object +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 ]) + + ... + 7. Return obj +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(); + + assert.sameValue(typedArray.length, 0); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js b/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js new file mode 100644 index 0000000000..232692fb69 --- /dev/null +++ b/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return a TypedArray object +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 20. Return O. + +includes: [testTypedArray.js] +---*/ + +var length = 10; +var typedArraySample = new Int8Array(length); + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(typedArraySample); + var bytesPerElement = TA.BYTES_PER_ELEMENT; + + assert.notSameValue(typedArray, typedArraySample); + assert.sameValue(typedArray.length, length); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js new file mode 100644 index 0000000000..db24d0bedd --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js @@ -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. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js new file mode 100644 index 0000000000..e4efc7980a --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Use prototype from new target if it's an Object +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [buffer], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js new file mode 100644 index 0000000000..e4864356d1 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Return abrupt completion getting newTarget's prototype +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var buffer = new ArrayBuffer(8); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [buffer], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js new file mode 100644 index 0000000000..7276dbfb14 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [1], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js b/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js new file mode 100644 index 0000000000..aa3faf6b87 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Use prototype from new target if it's an Object +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [1], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js b/test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js new file mode 100644 index 0000000000..3c34d9f1b4 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Return abrupt completion getting newTarget's prototype +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [1], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js new file mode 100644 index 0000000000..2cb363d3aa --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js new file mode 100644 index 0000000000..779775fb80 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray +description: > + Use prototype from new target if it's an Object +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js new file mode 100644 index 0000000000..48c489da4f --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray +description: > + Return abrupt completion getting newTarget's prototype +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 ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js new file mode 100644 index 0000000000..b2adc26a1b --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js @@ -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. +/*--- +id: sec-typedarray-object +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +newTarget.prototype = null; +var o = []; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [o], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js b/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js new file mode 100644 index 0000000000..92c12d6f0f --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Use prototype from new target if it's an Object +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js b/test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js new file mode 100644 index 0000000000..201a41c184 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt completion getting newTarget's prototype +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 3. Let O be ? AllocateTypedArray(TypedArray.[[TypedArrayConstructorName]], + NewTarget, "%TypedArrayPrototype%"). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var o = {}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [o], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js new file mode 100644 index 0000000000..f9788039ce --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js @@ -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. +/*--- +id: sec-typedarray-typedarray +description: > + Use prototype from %TypedArray% if newTarget's prototype is not an Object +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +newTarget.prototype = null; + +var sample = new Int8Array(8); + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [sample], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js new file mode 100644 index 0000000000..0aae23913b --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use prototype from new target if it's an Object +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + 2. Let obj be IntegerIndexedObjectCreate (proto, «[[ViewedArrayBuffer]], + [[TypedArrayName]], [[ByteLength]], [[ByteOffset]], [[ArrayLength]]» ). + ... + + 9.4.5.7 IntegerIndexedObjectCreate (prototype, internalSlotsList) + + ... + 10. Set the [[Prototype]] internal slot of A to prototype. + ... + 12. Return A. +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +function newTarget() {} +var proto = {}; +newTarget.prototype = proto; + +var sample = new Int8Array(8); + +testWithTypedArrayConstructors(function(TA) { + var ta = Reflect.construct(TA, [sample], newTarget); + + assert.sameValue(Object.getPrototypeOf(ta), proto); +}); diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js new file mode 100644 index 0000000000..e94b1d0569 --- /dev/null +++ b/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt completion getting newTarget's prototype +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 4. Let O be ? AllocateTypedArray(constructorName, NewTarget, + %TypedArrayPrototype%). + ... + + 22.2.4.2.1 Runtime Semantics: AllocateTypedArray (constructorName, newTarget, + defaultProto [ , length ]) + + 1. Let proto be ? GetPrototypeFromConstructor(newTarget, defaultProto). + ... + + 9.1.15 GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + ... + 3. Let proto be ? Get(constructor, "prototype"). + ... +features: [Reflect] +includes: [testTypedArray.js] +---*/ + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get() { + throw new Test262Error(); + } +}); + +var sample = new Int8Array(); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + Reflect.construct(TA, [sample], newTarget); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js b/test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js new file mode 100644 index 0000000000..689dac6af0 --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a RangeError if length is a float number +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. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(1.1); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js b/test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js new file mode 100644 index 0000000000..523a03616d --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a RangeError if length is a Infinity value +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. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(Infinity); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js b/test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js new file mode 100644 index 0000000000..8d71bb0167 --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a RangeError if length is NaN +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. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(NaN); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js b/test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js new file mode 100644 index 0000000000..0e3cc803fa --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a RangeError if length is a negative value +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. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(-1); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js b/test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js new file mode 100644 index 0000000000..0ec0daa8f1 --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js @@ -0,0 +1,53 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a RangeError when length argument is not a valid buffer size +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 ]) + + 6. Else, + a. Perform ? AllocateTypedArrayBuffer(obj, length). + ... + + 22.2.4.2.2 Runtime Semantics: AllocateTypedArrayBuffer ( O, length ) + + ... + 7. Let data be ? AllocateArrayBuffer(%ArrayBuffer%, byteLength). + ... + + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 3. Let block be ? CreateByteDataBlock(byteLength). + ... + + 6.2.6.1 CreateByteDataBlock (size) + + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... + +includes: [testTypedArray.js] +---*/ + +var length = Math.pow(2, 53); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(length); + }) +}); diff --git a/test/built-ins/TypedArrays/length-is-symbol-throws.js b/test/built-ins/TypedArrays/length-is-symbol-throws.js new file mode 100644 index 0000000000..8aba002238 --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-symbol-throws.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + If length is a Symbol, throw a TypeError exception. +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. + + ... + 4. Let numberLength be ? ToNumber(length). + ... +features: [Symbol] +includes: [testTypedArray.js] +---*/ + +var s = Symbol('1'); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(s); + }); +}); diff --git a/test/built-ins/TypedArrays/length-is-undefined-throws.js b/test/built-ins/TypedArrays/length-is-undefined-throws.js new file mode 100644 index 0000000000..dff4229e3c --- /dev/null +++ b/test/built-ins/TypedArrays/length-is-undefined-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + If length is undefined, throw a TypeError exception. +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. + + ... + 3. If length is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(undefined); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-as-array-returns.js b/test/built-ins/TypedArrays/object-argument-as-array-returns.js new file mode 100644 index 0000000000..eca1a8eae9 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-as-array-returns.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return typedArray from array argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +---*/ + +var obj = [7, 42]; + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7); + assert.sameValue(typedArray[1], 42); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js new file mode 100644 index 0000000000..1ce0a86936 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return typedArray from iterable argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 7; yield 42; + })(); + + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 2); + assert.sameValue(typedArray[0], 7); + assert.sameValue(typedArray[1], 42); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/object-argument-iterating-throws.js b/test/built-ins/TypedArrays/object-argument-iterating-throws.js new file mode 100644 index 0000000000..8f70545a90 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-iterating-throws.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from iterating object argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var obj = (function *() { + yield 0; + throw new Test262Error(); + })(); + + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js new file mode 100644 index 0000000000..dc6ed9ac46 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt when object @@iterator is not callable +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator] +---*/ + +var obj = function () {} + +testWithTypedArrayConstructors(function(TA) { + obj[Symbol.iterator] = {}; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = true; + assert.throws(TypeError, function() { + new TA(obj); + }); + + obj[Symbol.iterator] = 42; + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-iterator-throws.js b/test/built-ins/TypedArrays/object-argument-iterator-throws.js new file mode 100644 index 0000000000..b21043fe17 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-iterator-throws.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from getting object @@iterator +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 4. Let arrayLike be ? IterableToArrayLike(object). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator] +---*/ + +var obj = function () {} + +Object.defineProperty(obj, Symbol.iterator, { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js b/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js new file mode 100644 index 0000000000..1f802c2dd6 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from allocating array buffer with excessive length +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 6. Perform ? AllocateTypedArrayBuffer(O, len). + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var obj = { + length: Math.pow(2, 53) +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(RangeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js b/test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js new file mode 100644 index 0000000000..757a861e1b --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from length property as a Symbol on the object argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var obj = { + length: Symbol("1") +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-length-throws.js b/test/built-ins/TypedArrays/object-argument-length-throws.js new file mode 100644 index 0000000000..88bb9340e1 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-length-throws.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from getting length property on the object argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 5. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, "length", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-returns.js b/test/built-ins/TypedArrays/object-argument-returns.js new file mode 100644 index 0000000000..cabc2e2352 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-returns.js @@ -0,0 +1,32 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return typedArray from object argument +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var obj = { + "2": 42, + "3": "7", + "4": Symbol("1"), + length: 4 +}; + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(obj); + assert.sameValue(typedArray.length, 4); + assert.sameValue(typedArray[2], 42); + assert.sameValue(typedArray[3], 7); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/object-argument-throws-from-property.js b/test/built-ins/TypedArrays/object-argument-throws-from-property.js new file mode 100644 index 0000000000..2816f8f439 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-throws-from-property.js @@ -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. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from getting object property +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + ... +includes: [testTypedArray.js] +---*/ + +var obj = { + length: 4 +}; + +Object.defineProperty(obj, "2", { + get() { + throw new Test262Error(); + } +}); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-throws-setting-property.js b/test/built-ins/TypedArrays/object-argument-throws-setting-property.js new file mode 100644 index 0000000000..ee3f7c4c07 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-throws-setting-property.js @@ -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. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from setting property +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testTypedArray.js] +---*/ + +var obj = { + "2": { + valueOf() { + throw new Test262Error(); + } + }, + length: 4 +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(Test262Error, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js new file mode 100644 index 0000000000..c71516d209 --- /dev/null +++ b/test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Return abrupt from setting property +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(arrayLike, Pk). + c. Perform ? Set(O, Pk, kValue, true). + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var obj = { + "2": Symbol("1"), + length: 4 +}; + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + new TA(obj); + }); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js new file mode 100644 index 0000000000..240a2b58c7 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + ... + +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var tarray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(tarray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js new file mode 100644 index 0000000000..c8721e25c5 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js @@ -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. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + var o = { m() {} }; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = o.m; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js new file mode 100644 index 0000000000..895a2ea9f2 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {} + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js new file mode 100644 index 0000000000..12a2316d00 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + b. Let data be ? AllocateArrayBuffer(bufferConstructor, byteLength). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + var called = 0; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() {called++;}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js new file mode 100644 index 0000000000..bf8d3a4b8a --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js @@ -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. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {} + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var a = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(a.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js new file mode 100644 index 0000000000..26a3178a8c --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js @@ -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. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js new file mode 100644 index 0000000000..5055fa2f84 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js @@ -0,0 +1,90 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var sample1 = new Int8Array(); +var sample2 = new Int16Array(); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return 1; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return true; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return ''; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return null; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol('1'); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return s; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js new file mode 100644 index 0000000000..59483279f8 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js @@ -0,0 +1,41 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 18. Else, + a. Let bufferConstructor be ? SpeciesConstructor(srcData, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample1 = Int8Array; + var sample2 = Int16Array; + var sample = new (TA === Int8Array ? sample2 : sample1); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js new file mode 100644 index 0000000000..6c0ba821e3 --- /dev/null +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. +includes: [testTypedArray.js] +---*/ + +var sample1 = new Int8Array(7); +var sample2 = new Int16Array(7); + +testWithTypedArrayConstructors(function(TA) { + var sample = TA === Int8Array ? sample2 : sample1; + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js new file mode 100644 index 0000000000..5189f01b20 --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + var called = 0; + var custom = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function() { + called++; + }; + + ctor[Symbol.species].prototype = custom; + + var tarray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(tarray.buffer), custom); + assert.sameValue(called, 0); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js new file mode 100644 index 0000000000..1f0414068b --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + var o = { m() {} }; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = o.m; + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js new file mode 100644 index 0000000000..b3c461b1c5 --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on null buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(4); + var ctor = {} + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = null; + var typedArray = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(typedArray.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is null" + ); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js new file mode 100644 index 0000000000..5eace03d87 --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js @@ -0,0 +1,62 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from buffer.constructor.@@species.prototype +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + 8. Let targetBuffer be ? AllocateArrayBuffer(cloneConstructor, cloneLength). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + ... + + 24.1.1.1 AllocateArrayBuffer ( constructor, byteLength ) + + ... + 1. Let obj be ? OrdinaryCreateFromConstructor(constructor, + "%ArrayBufferPrototype%", « [[ArrayBufferData]], [[ArrayBufferByteLength]] » ) + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = function(){}.bind(null); + Object.defineProperty(ctor[Symbol.species], "prototype", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js new file mode 100644 index 0000000000..e07620e5d1 --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Use default ArrayBuffer constructor on undefined buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(4); + var ctor = {} + + sample.buffer.constructor = ctor; + + ctor[Symbol.species] = undefined; + var a = new TA(sample); + assert.sameValue( + Object.getPrototypeOf(a.buffer), + ArrayBuffer.prototype, + "buffer ctor is not called when species is undefined" + ); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js new file mode 100644 index 0000000000..04de7110ee --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt from getting typedArray argument's buffer.constructor.@@species +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + var ctor = {}; + + sample.buffer.constructor = ctor; + Object.defineProperty(ctor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js new file mode 100644 index 0000000000..f85aa5da7a --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js @@ -0,0 +1,94 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt completion from typedArray argument's buffer.constructor's value +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return 1; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return true; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return ''; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return null; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); + + var s = Symbol('1'); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + return s; + }, + configurable: true + }); + + assert.throws(TypeError, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js new file mode 100644 index 0000000000..f1d0afb65c --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js @@ -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. +/*--- +id: sec-typedarray-typedarray +description: > + Return abrupt completion from getting typedArray argument's buffer.constructor +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + + 24.1.1.4 CloneArrayBuffer ( srcBuffer, srcByteOffset [ , cloneConstructor ] ) + + ... + 2. If cloneConstructor is not present, then + a. Let cloneConstructor be ? SpeciesConstructor(srcBuffer, %ArrayBuffer%). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 2. Let C be ? Get(O, "constructor"). + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(); + Object.defineProperty(sample.buffer, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + new TA(sample); + }); +}); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js new file mode 100644 index 0000000000..4f67a1b930 --- /dev/null +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Same typedArray ctor argument returns a new cloned typedArray +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 17. If SameValue(elementType, srcType) is true, then + a. Let data be ? CloneArrayBuffer(srcData, srcByteOffset). + ... + 23. Return O. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var sample = new TA(7); + var typedArray = new TA(sample); + + assert.sameValue(typedArray.length, 7); + assert.notSameValue(typedArray, sample); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js new file mode 100644 index 0000000000..33bd136ace --- /dev/null +++ b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-buffer-byteoffset-length +description: > + Throws a TypeError if NewTarget is undefined. +info: > + 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has an [[ArrayBufferData]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(4); + assert.throws(TypeError, function() { + TA(buffer); + }); +}); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js new file mode 100644 index 0000000000..7ff0af5027 --- /dev/null +++ b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Throws a TypeError if NewTarget is undefined. +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. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var s = Symbol('1'); + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA(0); + }); + + assert.throws(TypeError, function() { + TA(NaN); + }); + + assert.throws(TypeError, function() { + TA(""); + }); + + assert.throws(TypeError, function() { + TA(true); + }); + + assert.throws(TypeError, function() { + TA(null); + }); + + assert.throws(TypeError, function() { + TA(undefined); + }); + + assert.throws(TypeError, function() { + TA(s); + }); +}); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js new file mode 100755 index 0000000000..4f76cb3520 --- /dev/null +++ b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray +description: > + Throws a TypeError if NewTarget is undefined. +info: > + 22.2.4.1 TypedArray( ) + + This description applies only if the TypedArray function is called with no + arguments. + + 1. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA(); + }); +}); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js new file mode 100644 index 0000000000..3c2db157b6 --- /dev/null +++ b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-object +description: > + Throws a TypeError if NewTarget is undefined. +info: > + 22.2.4.4 TypedArray ( object ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object does not have either a [[TypedArrayName]] or an [[ArrayBufferData]] + internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.throws(TypeError, function() { + TA({}); + }); + + assert.throws(TypeError, function() { + TA([]); + }); +}); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js new file mode 100644 index 0000000000..22f444cdc4 --- /dev/null +++ b/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-typedarray +description: > + Throws a TypeError if NewTarget is undefined. +info: > + 22.2.4.3 TypedArray ( typedArray ) + + This description applies only if the TypedArray function is called with at + least one argument and the Type of the first argument is Object and that + object has a [[TypedArrayName]] internal slot. + + ... + 2. If NewTarget is undefined, throw a TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(4); + + assert.throws(TypeError, function() { + TA(typedArray); + }); +}); From 7a8120fb63701333eb80ffd78e06adf65774eafb Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Thu, 4 Feb 2016 16:24:49 -0200 Subject: [PATCH 4/7] fixup! Add tests for TypedArrays constructors --- ...eoffset-throws-from-modulo-element-size.js | 2 +- .../buffer-argument-is-referenced.js | 4 +- .../called-with-length-return-object.js | 2 +- ...led-with-typedarray-return-new-instance.js | 1 - ...object-argument-length-excessive-throws.js | 1 - ...r-argument-buffer-ctor-species-not-ctor.js | 10 +++-- ...r-returns-abrupt-from-constructor-value.js | 41 +++---------------- ...-argument-returns-new-cloned-typedarray.js | 2 + 8 files changed, 19 insertions(+), 44 deletions(-) diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js index 6bab1c7e1e..0f0819e0ce 100644 --- a/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js +++ b/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js @@ -12,7 +12,7 @@ info: > object has an [[ArrayBufferData]] internal slot. ... - 9. If offset modulo elementSize ≠ 0, throw a RangeError exception. + 10. If offset modulo elementSize ≠ 0, throw a RangeError exception. ... includes: [testTypedArray.js] ---*/ diff --git a/test/built-ins/TypedArrays/buffer-argument-is-referenced.js b/test/built-ins/TypedArrays/buffer-argument-is-referenced.js index ef331db521..d9fbc5ead5 100644 --- a/test/built-ins/TypedArrays/buffer-argument-is-referenced.js +++ b/test/built-ins/TypedArrays/buffer-argument-is-referenced.js @@ -20,10 +20,12 @@ includes: [testTypedArray.js] testWithTypedArrayConstructors(function(TA) { var bpe = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(bpe * 4); + var buffer = new ArrayBuffer(bpe); var ta1 = new TA(buffer); var ta2 = new TA(buffer); + assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta2.buffer, buffer); assert.sameValue(ta1.buffer, ta2.buffer); }); diff --git a/test/built-ins/TypedArrays/called-with-length-return-object.js b/test/built-ins/TypedArrays/called-with-length-return-object.js index 669c113550..4ee88b9f3b 100644 --- a/test/built-ins/TypedArrays/called-with-length-return-object.js +++ b/test/built-ins/TypedArrays/called-with-length-return-object.js @@ -24,10 +24,10 @@ includes: [testTypedArray.js] testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(4); - var bytesPerElement = TA.BYTES_PER_ELEMENT; var length = typedArray.length; assert.sameValue(length, 4, "length"); + assert.sameValue(typedArray.constructor, TA); assert.sameValue( Object.getPrototypeOf(typedArray), TA.prototype, "Object.getPrototypeOf(typedArray)" diff --git a/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js b/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js index 232692fb69..6971dfcb18 100644 --- a/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js +++ b/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js @@ -22,7 +22,6 @@ var typedArraySample = new Int8Array(length); testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(typedArraySample); - var bytesPerElement = TA.BYTES_PER_ELEMENT; assert.notSameValue(typedArray, typedArraySample); assert.sameValue(typedArray.length, length); diff --git a/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js b/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js index 1f802c2dd6..f1d3034155 100644 --- a/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js +++ b/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js @@ -16,7 +16,6 @@ info: > 6. Perform ? AllocateTypedArrayBuffer(O, len). ... includes: [testTypedArray.js] -features: [Symbol] ---*/ var obj = { diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js index c8721e25c5..b082b0439d 100644 --- a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js @@ -30,15 +30,17 @@ features: [Symbol.species] var sample1 = new Int8Array(); var sample2 = new Int16Array(); +var ctor = function() { + throw new Test262Error(); +}; +var m = { m() {} }.m; +ctor[Symbol.species] = m; + testWithTypedArrayConstructors(function(TA) { var sample = TA === Int8Array ? sample2 : sample1; - var ctor = {}; - var o = { m() {} }; sample.buffer.constructor = ctor; - ctor[Symbol.species] = o.m; - assert.throws(TypeError, function() { new TA(sample); }); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js index 5055fa2f84..5ceb8d3686 100644 --- a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js +++ b/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js @@ -32,58 +32,29 @@ var sample2 = new Int16Array(); testWithTypedArrayConstructors(function(TA) { var sample = TA === Int8Array ? sample2 : sample1; - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return 1; - }, - configurable: true - }); + sample.buffer.constructor = 1; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return true; - }, - configurable: true - }); - + sample.buffer.constructor = true; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return ''; - }, - configurable: true - }); - + sample.buffer.constructor = ""; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return null; - }, - configurable: true - }); - + sample.buffer.constructor = null; assert.throws(TypeError, function() { new TA(sample); }); - var s = Symbol('1'); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return s; - }, - configurable: true - }); - + var s = Symbol("1"); + sample.buffer.constructor = s; assert.throws(TypeError, function() { new TA(sample); }); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js index 4f67a1b930..5d78db9db2 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js +++ b/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js @@ -25,5 +25,7 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(typedArray.length, 7); assert.notSameValue(typedArray, sample); + assert.notSameValue(typedArray.buffer, sample.buffer); + assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); }); From d033b160cb9370f9316289e3f1992de636da6dbc Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Thu, 4 Feb 2016 16:50:53 -0200 Subject: [PATCH 5/7] fixup! Add tests for TypedArrays constructors --- .../TypedArrays/object-argument-returns.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/built-ins/TypedArrays/object-argument-returns.js b/test/built-ins/TypedArrays/object-argument-returns.js index cabc2e2352..97d86287dd 100644 --- a/test/built-ins/TypedArrays/object-argument-returns.js +++ b/test/built-ins/TypedArrays/object-argument-returns.js @@ -17,16 +17,28 @@ features: [Symbol] ---*/ var obj = { + "0": null, "2": 42, "3": "7", - "4": Symbol("1"), - length: 4 + "4": NaN, + "5": Symbol("1"), + length: 5 }; testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(obj); assert.sameValue(typedArray.length, 4); + assert.sameValue(typedArray[0], 0); assert.sameValue(typedArray[2], 42); assert.sameValue(typedArray[3], 7); + assert.sameValue(typedArray[5], undefined); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); + + if (TA === Float32Array || TA === Float64Array) { + assert.sameValue(typedArray[1], NaN); + assert.sameValue(typedArray[4], NaN); + } else { + assert.sameValue(typedArray[1], 0); + assert.sameValue(typedArray[4], 0); + } }); From 0a30413b49b93604b7b89cd0c06ce9bd260605d9 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Thu, 4 Feb 2016 17:06:56 -0200 Subject: [PATCH 6/7] fixup! rename test files + review fixes --- ...offset-throws-from-modulo-element-size.js} | 0 ...ffer-arg-byteoffset-is-negative-throws.js} | 0 ...buffer-arg-byteoffset-is-symbol-throws.js} | 0 ...offset-throws-from-modulo-element-size.js} | 0 ...buffer-arg-byteoffset-to-number-throws.js} | 0 ... buffer-arg-custom-proto-access-throws.js} | 0 ...> buffer-arg-defined-length-and-offset.js} | 12 ++---- ...length.js => buffer-arg-defined-length.js} | 2 + ... => buffer-arg-defined-negative-length.js} | 11 ++++-- ...offset.js => buffer-arg-defined-offset.js} | 2 + ... => buffer-arg-excessive-length-throws.js} | 7 ++-- ... => buffer-arg-excessive-offset-throws.js} | 9 +++-- ...r-arg-invoked-with-undefined-newtarget.js} | 0 ...erenced.js => buffer-arg-is-referenced.js} | 0 ....js => buffer-arg-length-access-throws.js} | 0 ... => buffer-arg-length-is-symbol-throws.js} | 0 ....js => buffer-arg-returns-new-instance.js} | 4 +- ... buffer-arg-use-custom-proto-if-object.js} | 1 + ...lt-proto-if-custom-proto-is-not-object.js} | 1 + ... length-arg-custom-proto-access-throws.js} | 0 ... length-arg-is-float-throws-rangeerror.js} | 0 ...ngth-arg-is-infinity-throws-rangeerror.js} | 0 ...=> length-arg-is-nan-throws-rangeerror.js} | 0 ...g-is-negative-number-throws-rangeerror.js} | 0 ...ot-valid-buffer-size-throws-rangeerror.js} | 0 ...rows.js => length-arg-is-symbol-throws.js} | 0 ...s.js => length-arg-is-undefined-throws.js} | 0 .../length-arg-minus-signal-zero.js | 28 +++++++++++++ ...object.js => length-arg-returns-object.js} | 5 +-- ... length-arg-undefined-newtarget-throws.js} | 0 ... length-arg-use-custom-proto-if-object.js} | 1 + ...lt-proto-if-custom-proto-is-not-object.js} | 1 + ... => no-args-custom-proto-access-throws.js} | 0 ...rn-object.js => no-args-returns-object.js} | 0 ... => no-args-undefined-newtarget-throws.js} | 0 ... => no-args-use-custom-proto-if-object.js} | 1 + ...lt-proto-if-custom-proto-is-not-object.js} | 1 + ...urns.js => object-arg-as-array-returns.js} | 1 + ...ject-arg-as-generator-iterable-returns.js} | 1 + ... object-arg-custom-proto-access-throws.js} | 0 ...rows.js => object-arg-iterating-throws.js} | 0 ...bject-arg-iterator-not-callable-throws.js} | 0 ...hrows.js => object-arg-iterator-throws.js} | 0 ... => object-arg-length-excessive-throws.js} | 0 ... => object-arg-length-is-symbol-throws.js} | 0 ...-throws.js => object-arg-length-throws.js} | 0 ...ument-returns.js => object-arg-returns.js} | 3 +- ....js => object-arg-throws-from-property.js} | 0 ... => object-arg-throws-setting-property.js} | 0 ...ect-arg-throws-setting-symbol-property.js} | 0 ... object-arg-undefined-newtarget-throws.js} | 0 ... object-arg-use-custom-proto-if-object.js} | 1 + ...lt-proto-if-custom-proto-is-not-object.js} | 1 + ...edarray-arg-custom-proto-access-throws.js} | 0 ...g-other-ctor-buffer-ctor-access-throws.js} | 2 +- ...-other-ctor-buffer-ctor-custom-species.js} | 4 +- ...her-ctor-buffer-ctor-not-object-throws.js} | 0 ...ctor-buffer-ctor-species-access-throws.js} | 0 ...or-buffer-ctor-species-not-ctor-throws.js} | 0 ...rg-other-ctor-buffer-ctor-species-null.js} | 0 ...r-buffer-ctor-species-prototype-throws.js} | 0 ...her-ctor-buffer-ctor-species-undefined.js} | 0 ...-arg-other-ctor-returns-new-typedarray.js} | 0 ...=> typedarray-arg-returns-new-instance.js} | 0 ...rg-same-ctor-buffer-ctor-access-throws.js} | 0 ...g-same-ctor-buffer-ctor-species-custom.js} | 4 +- ...same-ctor-buffer-ctor-species-not-ctor.js} | 4 +- ...arg-same-ctor-buffer-ctor-species-null.js} | 0 ...r-buffer-ctor-species-prototype-throws.js} | 2 +- ...g-same-ctor-buffer-ctor-species-throws.js} | 2 +- ...ame-ctor-buffer-ctor-species-undefined.js} | 4 +- ...-ctor-buffer-ctor-value-not-obj-throws.js} | 39 +++---------------- ...ame-ctor-returns-new-cloned-typedarray.js} | 0 ...edarray-arg-undefined-newtarget-throws.js} | 0 ...edarray-arg-use-custom-proto-if-object.js} | 1 + ...lt-proto-if-custom-proto-is-not-object.js} | 1 + 76 files changed, 86 insertions(+), 70 deletions(-) rename test/built-ins/TypedArrays/{buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js => buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-byteoffset-is-negative-throws.js => buffer-arg-byteoffset-is-negative-throws.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-byteoffset-is-symbol-throws.js => buffer-arg-byteoffset-is-symbol-throws.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-byteoffset-throws-from-modulo-element-size.js => buffer-arg-byteoffset-throws-from-modulo-element-size.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-byteoffset-to-number-throws.js => buffer-arg-byteoffset-to-number-throws.js} (100%) rename test/built-ins/TypedArrays/{get-prototype-with-buffer-argument-returns-abrupt.js => buffer-arg-custom-proto-access-throws.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-defined-length-and-offset.js => buffer-arg-defined-length-and-offset.js} (82%) rename test/built-ins/TypedArrays/{buffer-argument-defined-length.js => buffer-arg-defined-length.js} (92%) rename test/built-ins/TypedArrays/{buffer-argument-defined-negative-length.js => buffer-arg-defined-negative-length.js} (81%) rename test/built-ins/TypedArrays/{buffer-argument-defined-offset.js => buffer-arg-defined-offset.js} (92%) rename test/built-ins/TypedArrays/{buffer-argument-excessive-length-throws.js => buffer-arg-excessive-length-throws.js} (89%) rename test/built-ins/TypedArrays/{buffer-argument-excessive-offset-throws.js => buffer-arg-excessive-offset-throws.js} (87%) rename test/built-ins/TypedArrays/{undefined-newtarget-invoked-with-arraybuffer.js => buffer-arg-invoked-with-undefined-newtarget.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-is-referenced.js => buffer-arg-is-referenced.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-returns-abrupt-from-length.js => buffer-arg-length-access-throws.js} (100%) rename test/built-ins/TypedArrays/{buffer-argument-returns-abrupt-from-length-symbol.js => buffer-arg-length-is-symbol-throws.js} (100%) rename test/built-ins/TypedArrays/{buffer-single-argument-single.js => buffer-arg-returns-new-instance.js} (87%) rename test/built-ins/TypedArrays/{get-prototype-with-buffer-argument-proto-is-object.js => buffer-arg-use-custom-proto-if-object.js} (97%) rename test/built-ins/TypedArrays/{get-prototype-with-buffer-argument-proto-is-not-object.js => buffer-arg-use-default-proto-if-custom-proto-is-not-object.js} (97%) rename test/built-ins/TypedArrays/{get-prototype-with-length-argument-returns-abrupt.js => length-arg-custom-proto-access-throws.js} (100%) rename test/built-ins/TypedArrays/{length-is-float-throws-rangeerror.js => length-arg-is-float-throws-rangeerror.js} (100%) rename test/built-ins/TypedArrays/{length-is-infinity-throws-rangeerror.js => length-arg-is-infinity-throws-rangeerror.js} (100%) rename test/built-ins/TypedArrays/{length-is-nan-throws-rangeerror.js => length-arg-is-nan-throws-rangeerror.js} (100%) rename test/built-ins/TypedArrays/{length-is-negative-number-throws-rangeerror.js => length-arg-is-negative-number-throws-rangeerror.js} (100%) rename test/built-ins/TypedArrays/{length-is-not-valid-buffer-size-throws-rangeerror.js => length-arg-is-not-valid-buffer-size-throws-rangeerror.js} (100%) rename test/built-ins/TypedArrays/{length-is-symbol-throws.js => length-arg-is-symbol-throws.js} (100%) rename test/built-ins/TypedArrays/{length-is-undefined-throws.js => length-arg-is-undefined-throws.js} (100%) create mode 100644 test/built-ins/TypedArrays/length-arg-minus-signal-zero.js rename test/built-ins/TypedArrays/{called-with-length-return-object.js => length-arg-returns-object.js} (88%) rename test/built-ins/TypedArrays/{undefined-newtarget-invoked-with-length.js => length-arg-undefined-newtarget-throws.js} (100%) rename test/built-ins/TypedArrays/{get-prototype-with-length-argument-proto-is-object.js => length-arg-use-custom-proto-if-object.js} (96%) rename test/built-ins/TypedArrays/{get-prototype-with-length-argument-proto-is-not-object.js => length-arg-use-default-proto-if-custom-proto-is-not-object.js} (97%) rename test/built-ins/TypedArrays/{get-prototype-with-no-arguments-returns-abrupt.js => no-args-custom-proto-access-throws.js} (100%) rename test/built-ins/TypedArrays/{called-with-no-arguments-return-object.js => no-args-returns-object.js} (100%) rename test/built-ins/TypedArrays/{undefined-newtarget-invoked-with-no-arguments.js => no-args-undefined-newtarget-throws.js} (100%) rename test/built-ins/TypedArrays/{get-prototype-with-no-arguments-proto-is-object.js => no-args-use-custom-proto-if-object.js} (96%) rename test/built-ins/TypedArrays/{get-prototype-with-no-arguments-proto-is-not-object.js => no-args-use-default-proto-if-custom-proto-is-not-object.js} (96%) rename test/built-ins/TypedArrays/{object-argument-as-array-returns.js => object-arg-as-array-returns.js} (94%) rename test/built-ins/TypedArrays/{object-argument-as-generator-iterable-returns.js => object-arg-as-generator-iterable-returns.js} (94%) rename test/built-ins/TypedArrays/{get-prototype-with-object-argument-returns-abrupt.js => object-arg-custom-proto-access-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-iterating-throws.js => object-arg-iterating-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-iterator-not-callable-throws.js => object-arg-iterator-not-callable-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-iterator-throws.js => object-arg-iterator-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-length-excessive-throws.js => object-arg-length-excessive-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-length-is-symbol-throws.js => object-arg-length-is-symbol-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-length-throws.js => object-arg-length-throws.js} (100%) rename test/built-ins/TypedArrays/{object-argument-returns.js => object-arg-returns.js} (93%) rename test/built-ins/TypedArrays/{object-argument-throws-from-property.js => object-arg-throws-from-property.js} (100%) rename test/built-ins/TypedArrays/{object-argument-throws-setting-property.js => object-arg-throws-setting-property.js} (100%) rename test/built-ins/TypedArrays/{object-argument-throws-setting-symbol-property.js => object-arg-throws-setting-symbol-property.js} (100%) rename test/built-ins/TypedArrays/{undefined-newtarget-invoked-with-object.js => object-arg-undefined-newtarget-throws.js} (100%) rename test/built-ins/TypedArrays/{get-prototype-with-object-argument-proto-is-object.js => object-arg-use-custom-proto-if-object.js} (97%) rename test/built-ins/TypedArrays/{get-prototype-with-object-argument-proto-is-not-object.js => object-arg-use-default-proto-if-custom-proto-is-not-object.js} (97%) rename test/built-ins/TypedArrays/{get-prototype-with-typedarray-argument-returns-abrupt.js => typedarray-arg-custom-proto-access-throws.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js => typedarray-arg-other-ctor-buffer-ctor-access-throws.js} (98%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-ctor-species-custom.js => typedarray-arg-other-ctor-buffer-ctor-custom-species.js} (92%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js => typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js => typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js => typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-ctor-species-null.js => typedarray-arg-other-ctor-buffer-ctor-species-null.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js => typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-buffer-ctor-species-undefined.js => typedarray-arg-other-ctor-buffer-ctor-species-undefined.js} (100%) rename test/built-ins/TypedArrays/{other-typedarray-ctor-argument-returns-new-typedarray.js => typedarray-arg-other-ctor-returns-new-typedarray.js} (100%) rename test/built-ins/TypedArrays/{called-with-typedarray-return-new-instance.js => typedarray-arg-returns-new-instance.js} (100%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js => typedarray-arg-same-ctor-buffer-ctor-access-throws.js} (100%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-ctor-species-custom.js => typedarray-arg-same-ctor-buffer-ctor-species-custom.js} (93%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js => typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js} (96%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-ctor-species-null.js => typedarray-arg-same-ctor-buffer-ctor-species-null.js} (100%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js => typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js} (98%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js => typedarray-arg-same-ctor-buffer-ctor-species-throws.js} (98%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-ctor-species-undefined.js => typedarray-arg-same-ctor-buffer-ctor-species-undefined.js} (94%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js => typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js} (69%) rename test/built-ins/TypedArrays/{same-typedarray-ctor-argument-returns-new-cloned-typedarray.js => typedarray-arg-same-ctor-returns-new-cloned-typedarray.js} (100%) rename test/built-ins/TypedArrays/{undefined-newtarget-invoked-with-typedarray.js => typedarray-arg-undefined-newtarget-throws.js} (100%) rename test/built-ins/TypedArrays/{get-prototype-with-typedarray-argument-proto-is-object.js => typedarray-arg-use-custom-proto-if-object.js} (96%) rename test/built-ins/TypedArrays/{get-prototype-with-typedarray-argument-proto-is-not-object.js => typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js} (97%) diff --git a/test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-bufferbyteoffset-throws-from-modulo-element-size.js rename to test/built-ins/TypedArrays/buffer-arg-bufferbyteoffset-throws-from-modulo-element-size.js diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-byteoffset-is-negative-throws.js rename to test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-throws.js diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-byteoffset-is-symbol-throws.js rename to test/built-ins/TypedArrays/buffer-arg-byteoffset-is-symbol-throws.js diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-byteoffset-throws-from-modulo-element-size.js rename to test/built-ins/TypedArrays/buffer-arg-byteoffset-throws-from-modulo-element-size.js diff --git a/test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-byteoffset-to-number-throws.js rename to test/built-ins/TypedArrays/buffer-arg-byteoffset-to-number-throws.js diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js b/test/built-ins/TypedArrays/buffer-arg-custom-proto-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/get-prototype-with-buffer-argument-returns-abrupt.js rename to test/built-ins/TypedArrays/buffer-arg-custom-proto-access-throws.js diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js b/test/built-ins/TypedArrays/buffer-arg-defined-length-and-offset.js similarity index 82% rename from test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js rename to test/built-ins/TypedArrays/buffer-arg-defined-length-and-offset.js index e305ab731e..0b8f5ff0cd 100644 --- a/test/built-ins/TypedArrays/buffer-argument-defined-length-and-offset.js +++ b/test/built-ins/TypedArrays/buffer-arg-defined-length-and-offset.js @@ -20,16 +20,12 @@ testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(buffer, offset, 2); assert.sameValue(ta1.length, 2, "ta1.length"); assert.sameValue(ta1.buffer, buffer, "ta1.buffer"); - assert.sameValue( - Object.getPrototypeOf(ta1), TA.prototype, - "Object.getPrototypeOf(ta1)" - ); + assert.sameValue(ta1.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); var ta2 = new TA(buffer, offset, 0); assert.sameValue(ta2.length, 0, "ta2.length"); assert.sameValue(ta2.buffer, buffer, "ta2.buffer"); - assert.sameValue( - Object.getPrototypeOf(ta2), TA.prototype, - "Object.getPrototypeOf(ta2)" - ); + assert.sameValue(ta2.constructor, TA); + assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-length.js b/test/built-ins/TypedArrays/buffer-arg-defined-length.js similarity index 92% rename from test/built-ins/TypedArrays/buffer-argument-defined-length.js rename to test/built-ins/TypedArrays/buffer-arg-defined-length.js index 125c224c9b..f30447bec7 100644 --- a/test/built-ins/TypedArrays/buffer-argument-defined-length.js +++ b/test/built-ins/TypedArrays/buffer-arg-defined-length.js @@ -22,10 +22,12 @@ testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(buffer, 0, length); assert.sameValue(ta1.length, length); assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); var ta2 = new TA(buffer, 0, 0); assert.sameValue(ta2.length, 0); assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js b/test/built-ins/TypedArrays/buffer-arg-defined-negative-length.js similarity index 81% rename from test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js rename to test/built-ins/TypedArrays/buffer-arg-defined-negative-length.js index 8bb321f3da..c1cfec4afc 100644 --- a/test/built-ins/TypedArrays/buffer-argument-defined-negative-length.js +++ b/test/built-ins/TypedArrays/buffer-arg-defined-negative-length.js @@ -16,26 +16,29 @@ includes: [testTypedArray.js] testWithTypedArrayConstructors(function(TA) { var bpe = TA.BYTES_PER_ELEMENT; - var length = 4; - var buffer = new ArrayBuffer(bpe * length * 4); + var buffer = new ArrayBuffer(bpe * 2); var ta1 = new TA(buffer, 0, -1); assert.sameValue(ta1.length, 0); assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); var ta2 = new TA(buffer, 0, -Infinity); assert.sameValue(ta2.length, 0); assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); - var ta3 = new TA(buffer, 8, -1); + var ta3 = new TA(buffer, bpe, -1); assert.sameValue(ta3.length, 0); assert.sameValue(ta3.buffer, buffer); + assert.sameValue(ta3.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta3), TA.prototype); - var ta4 = new TA(buffer, 8, -Infinity); + var ta4 = new TA(buffer, bpe, -Infinity); assert.sameValue(ta4.length, 0); assert.sameValue(ta4.buffer, buffer); + assert.sameValue(ta4.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta4), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/buffer-argument-defined-offset.js b/test/built-ins/TypedArrays/buffer-arg-defined-offset.js similarity index 92% rename from test/built-ins/TypedArrays/buffer-argument-defined-offset.js rename to test/built-ins/TypedArrays/buffer-arg-defined-offset.js index bc7e49fc68..82d28924bd 100644 --- a/test/built-ins/TypedArrays/buffer-argument-defined-offset.js +++ b/test/built-ins/TypedArrays/buffer-arg-defined-offset.js @@ -20,10 +20,12 @@ testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(buffer, bpe * 2); assert.sameValue(ta1.length, 2); assert.sameValue(ta1.buffer, buffer); + assert.sameValue(ta1.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); var ta2 = new TA(buffer, 0); assert.sameValue(ta2.length, 4); assert.sameValue(ta2.buffer, buffer); + assert.sameValue(ta2.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js b/test/built-ins/TypedArrays/buffer-arg-excessive-length-throws.js similarity index 89% rename from test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js rename to test/built-ins/TypedArrays/buffer-arg-excessive-length-throws.js index 439b550879..7313edf2b1 100644 --- a/test/built-ins/TypedArrays/buffer-argument-excessive-length-throws.js +++ b/test/built-ins/TypedArrays/buffer-arg-excessive-length-throws.js @@ -20,10 +20,11 @@ info: > includes: [testTypedArray.js] ---*/ -var buffer = new ArrayBuffer(8); - testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe); + assert.throws(RangeError, function() { - new TA(buffer, 0, 16); + new TA(buffer, 0, bpe * 2); }); }); diff --git a/test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js b/test/built-ins/TypedArrays/buffer-arg-excessive-offset-throws.js similarity index 87% rename from test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js rename to test/built-ins/TypedArrays/buffer-arg-excessive-offset-throws.js index 9270c51ebc..26c12c27ef 100644 --- a/test/built-ins/TypedArrays/buffer-argument-excessive-offset-throws.js +++ b/test/built-ins/TypedArrays/buffer-arg-excessive-offset-throws.js @@ -20,14 +20,15 @@ info: > includes: [testTypedArray.js] ---*/ -var buffer = new ArrayBuffer(8); - testWithTypedArrayConstructors(function(TA) { + var bpe = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(bpe); + assert.throws(RangeError, function() { - new TA(buffer, 16); + new TA(buffer, bpe * 2); }); assert.throws(RangeError, function() { - new TA(buffer, 16, undefined); + new TA(buffer, bpe * 2, undefined); }); }); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js b/test/built-ins/TypedArrays/buffer-arg-invoked-with-undefined-newtarget.js similarity index 100% rename from test/built-ins/TypedArrays/undefined-newtarget-invoked-with-arraybuffer.js rename to test/built-ins/TypedArrays/buffer-arg-invoked-with-undefined-newtarget.js diff --git a/test/built-ins/TypedArrays/buffer-argument-is-referenced.js b/test/built-ins/TypedArrays/buffer-arg-is-referenced.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-is-referenced.js rename to test/built-ins/TypedArrays/buffer-arg-is-referenced.js diff --git a/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js b/test/built-ins/TypedArrays/buffer-arg-length-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length.js rename to test/built-ins/TypedArrays/buffer-arg-length-access-throws.js diff --git a/test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js b/test/built-ins/TypedArrays/buffer-arg-length-is-symbol-throws.js similarity index 100% rename from test/built-ins/TypedArrays/buffer-argument-returns-abrupt-from-length-symbol.js rename to test/built-ins/TypedArrays/buffer-arg-length-is-symbol-throws.js diff --git a/test/built-ins/TypedArrays/buffer-single-argument-single.js b/test/built-ins/TypedArrays/buffer-arg-returns-new-instance.js similarity index 87% rename from test/built-ins/TypedArrays/buffer-single-argument-single.js rename to test/built-ins/TypedArrays/buffer-arg-returns-new-instance.js index 62892b4c36..2fcbf0a6fa 100644 --- a/test/built-ins/TypedArrays/buffer-single-argument-single.js +++ b/test/built-ins/TypedArrays/buffer-arg-returns-new-instance.js @@ -3,7 +3,7 @@ /*--- id: sec-typedarray-buffer-byteoffset-length description: > - Return new typedArray from undefined defined offset + Return new typedArray from undefined offset and length info: > 22.2.4.5 TypedArray ( buffer [ , byteOffset [ , length ] ] ) @@ -20,11 +20,13 @@ testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(buffer1); assert.sameValue(ta1.length, 4); assert.sameValue(ta1.buffer, buffer1); + assert.sameValue(ta1.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta1), TA.prototype); var buffer2 = new ArrayBuffer(0); var ta2 = new TA(buffer2); assert.sameValue(ta2.length, 0); assert.sameValue(ta2.buffer, buffer2); + assert.sameValue(ta2.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta2), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js b/test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js rename to test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object.js index e4efc7980a..2dc855cd9c 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-object.js +++ b/test/built-ins/TypedArrays/buffer-arg-use-custom-proto-if-object.js @@ -43,5 +43,6 @@ newTarget.prototype = proto; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [buffer], newTarget); + assert.sameValue(ta.constructor, Object); assert.sameValue(Object.getPrototypeOf(ta), proto); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js rename to test/built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js index db24d0bedd..ea90fbd350 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-buffer-argument-proto-is-not-object.js +++ b/test/built-ins/TypedArrays/buffer-arg-use-default-proto-if-custom-proto-is-not-object.js @@ -41,5 +41,6 @@ newTarget.prototype = null; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [buffer], newTarget); + assert.sameValue(ta.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js b/test/built-ins/TypedArrays/length-arg-custom-proto-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/get-prototype-with-length-argument-returns-abrupt.js rename to test/built-ins/TypedArrays/length-arg-custom-proto-access-throws.js diff --git a/test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js b/test/built-ins/TypedArrays/length-arg-is-float-throws-rangeerror.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-float-throws-rangeerror.js rename to test/built-ins/TypedArrays/length-arg-is-float-throws-rangeerror.js diff --git a/test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js b/test/built-ins/TypedArrays/length-arg-is-infinity-throws-rangeerror.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-infinity-throws-rangeerror.js rename to test/built-ins/TypedArrays/length-arg-is-infinity-throws-rangeerror.js diff --git a/test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js b/test/built-ins/TypedArrays/length-arg-is-nan-throws-rangeerror.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-nan-throws-rangeerror.js rename to test/built-ins/TypedArrays/length-arg-is-nan-throws-rangeerror.js diff --git a/test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js b/test/built-ins/TypedArrays/length-arg-is-negative-number-throws-rangeerror.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-negative-number-throws-rangeerror.js rename to test/built-ins/TypedArrays/length-arg-is-negative-number-throws-rangeerror.js diff --git a/test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js b/test/built-ins/TypedArrays/length-arg-is-not-valid-buffer-size-throws-rangeerror.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-not-valid-buffer-size-throws-rangeerror.js rename to test/built-ins/TypedArrays/length-arg-is-not-valid-buffer-size-throws-rangeerror.js diff --git a/test/built-ins/TypedArrays/length-is-symbol-throws.js b/test/built-ins/TypedArrays/length-arg-is-symbol-throws.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-symbol-throws.js rename to test/built-ins/TypedArrays/length-arg-is-symbol-throws.js diff --git a/test/built-ins/TypedArrays/length-is-undefined-throws.js b/test/built-ins/TypedArrays/length-arg-is-undefined-throws.js similarity index 100% rename from test/built-ins/TypedArrays/length-is-undefined-throws.js rename to test/built-ins/TypedArrays/length-arg-is-undefined-throws.js diff --git a/test/built-ins/TypedArrays/length-arg-minus-signal-zero.js b/test/built-ins/TypedArrays/length-arg-minus-signal-zero.js new file mode 100644 index 0000000000..56e685150f --- /dev/null +++ b/test/built-ins/TypedArrays/length-arg-minus-signal-zero.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-typedarray-length +description: > + Does not throw when length is -0 +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. + + ... + 4. Let numberLength be ? ToNumber(length). + 5. Let elementLength be ToLength(numberLength). + 6. If SameValueZero(numberLength, elementLength) is false, throw a RangeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var typedArray = new TA(-0); + + assert.sameValue(typedArray.length, 0, "length"); + assert.sameValue(typedArray.constructor, TA); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); +}); diff --git a/test/built-ins/TypedArrays/called-with-length-return-object.js b/test/built-ins/TypedArrays/length-arg-returns-object.js similarity index 88% rename from test/built-ins/TypedArrays/called-with-length-return-object.js rename to test/built-ins/TypedArrays/length-arg-returns-object.js index 4ee88b9f3b..0b12fc0c72 100644 --- a/test/built-ins/TypedArrays/called-with-length-return-object.js +++ b/test/built-ins/TypedArrays/length-arg-returns-object.js @@ -28,8 +28,5 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(length, 4, "length"); assert.sameValue(typedArray.constructor, TA); - assert.sameValue( - Object.getPrototypeOf(typedArray), TA.prototype, - "Object.getPrototypeOf(typedArray)" - ); + assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js b/test/built-ins/TypedArrays/length-arg-undefined-newtarget-throws.js similarity index 100% rename from test/built-ins/TypedArrays/undefined-newtarget-invoked-with-length.js rename to test/built-ins/TypedArrays/length-arg-undefined-newtarget-throws.js diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js b/test/built-ins/TypedArrays/length-arg-use-custom-proto-if-object.js similarity index 96% rename from test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js rename to test/built-ins/TypedArrays/length-arg-use-custom-proto-if-object.js index aa3faf6b87..23689ffd02 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-object.js +++ b/test/built-ins/TypedArrays/length-arg-use-custom-proto-if-object.js @@ -39,5 +39,6 @@ newTarget.prototype = proto; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [1], newTarget); + assert.sameValue(ta.constructor, Object); assert.sameValue(Object.getPrototypeOf(ta), proto); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/length-arg-use-default-proto-if-custom-proto-is-not-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js rename to test/built-ins/TypedArrays/length-arg-use-default-proto-if-custom-proto-is-not-object.js index 7276dbfb14..b805c76599 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-length-argument-proto-is-not-object.js +++ b/test/built-ins/TypedArrays/length-arg-use-default-proto-if-custom-proto-is-not-object.js @@ -37,5 +37,6 @@ newTarget.prototype = null; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [1], newTarget); + assert.sameValue(ta.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js b/test/built-ins/TypedArrays/no-args-custom-proto-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/get-prototype-with-no-arguments-returns-abrupt.js rename to test/built-ins/TypedArrays/no-args-custom-proto-access-throws.js diff --git a/test/built-ins/TypedArrays/called-with-no-arguments-return-object.js b/test/built-ins/TypedArrays/no-args-returns-object.js similarity index 100% rename from test/built-ins/TypedArrays/called-with-no-arguments-return-object.js rename to test/built-ins/TypedArrays/no-args-returns-object.js diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js b/test/built-ins/TypedArrays/no-args-undefined-newtarget-throws.js similarity index 100% rename from test/built-ins/TypedArrays/undefined-newtarget-invoked-with-no-arguments.js rename to test/built-ins/TypedArrays/no-args-undefined-newtarget-throws.js diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js b/test/built-ins/TypedArrays/no-args-use-custom-proto-if-object.js similarity index 96% rename from test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js rename to test/built-ins/TypedArrays/no-args-use-custom-proto-if-object.js index 779775fb80..a2a645fa6b 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-object.js +++ b/test/built-ins/TypedArrays/no-args-use-custom-proto-if-object.js @@ -39,5 +39,6 @@ newTarget.prototype = proto; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [], newTarget); + assert.sameValue(ta.constructor, Object); assert.sameValue(Object.getPrototypeOf(ta), proto); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js b/test/built-ins/TypedArrays/no-args-use-default-proto-if-custom-proto-is-not-object.js similarity index 96% rename from test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js rename to test/built-ins/TypedArrays/no-args-use-default-proto-if-custom-proto-is-not-object.js index 2cb363d3aa..c56e8f20a0 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-no-arguments-proto-is-not-object.js +++ b/test/built-ins/TypedArrays/no-args-use-default-proto-if-custom-proto-is-not-object.js @@ -37,5 +37,6 @@ newTarget.prototype = null; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [], newTarget); + assert.sameValue(ta.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/object-argument-as-array-returns.js b/test/built-ins/TypedArrays/object-arg-as-array-returns.js similarity index 94% rename from test/built-ins/TypedArrays/object-argument-as-array-returns.js rename to test/built-ins/TypedArrays/object-arg-as-array-returns.js index eca1a8eae9..8c532e2b7b 100644 --- a/test/built-ins/TypedArrays/object-argument-as-array-returns.js +++ b/test/built-ins/TypedArrays/object-arg-as-array-returns.js @@ -22,5 +22,6 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(typedArray.length, 2); assert.sameValue(typedArray[0], 7); assert.sameValue(typedArray[1], 42); + assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js b/test/built-ins/TypedArrays/object-arg-as-generator-iterable-returns.js similarity index 94% rename from test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js rename to test/built-ins/TypedArrays/object-arg-as-generator-iterable-returns.js index 1ce0a86936..2837e91e5a 100644 --- a/test/built-ins/TypedArrays/object-argument-as-generator-iterable-returns.js +++ b/test/built-ins/TypedArrays/object-arg-as-generator-iterable-returns.js @@ -24,5 +24,6 @@ testWithTypedArrayConstructors(function(TA) { assert.sameValue(typedArray.length, 2); assert.sameValue(typedArray[0], 7); assert.sameValue(typedArray[1], 42); + assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js b/test/built-ins/TypedArrays/object-arg-custom-proto-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/get-prototype-with-object-argument-returns-abrupt.js rename to test/built-ins/TypedArrays/object-arg-custom-proto-access-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-iterating-throws.js b/test/built-ins/TypedArrays/object-arg-iterating-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-iterating-throws.js rename to test/built-ins/TypedArrays/object-arg-iterating-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js b/test/built-ins/TypedArrays/object-arg-iterator-not-callable-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-iterator-not-callable-throws.js rename to test/built-ins/TypedArrays/object-arg-iterator-not-callable-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-iterator-throws.js b/test/built-ins/TypedArrays/object-arg-iterator-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-iterator-throws.js rename to test/built-ins/TypedArrays/object-arg-iterator-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-length-excessive-throws.js b/test/built-ins/TypedArrays/object-arg-length-excessive-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-length-excessive-throws.js rename to test/built-ins/TypedArrays/object-arg-length-excessive-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js b/test/built-ins/TypedArrays/object-arg-length-is-symbol-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-length-is-symbol-throws.js rename to test/built-ins/TypedArrays/object-arg-length-is-symbol-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-length-throws.js b/test/built-ins/TypedArrays/object-arg-length-throws.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-length-throws.js rename to test/built-ins/TypedArrays/object-arg-length-throws.js diff --git a/test/built-ins/TypedArrays/object-argument-returns.js b/test/built-ins/TypedArrays/object-arg-returns.js similarity index 93% rename from test/built-ins/TypedArrays/object-argument-returns.js rename to test/built-ins/TypedArrays/object-arg-returns.js index 97d86287dd..6ac5b219a8 100644 --- a/test/built-ins/TypedArrays/object-argument-returns.js +++ b/test/built-ins/TypedArrays/object-arg-returns.js @@ -27,11 +27,12 @@ var obj = { testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(obj); - assert.sameValue(typedArray.length, 4); + assert.sameValue(typedArray.length, 5); assert.sameValue(typedArray[0], 0); assert.sameValue(typedArray[2], 42); assert.sameValue(typedArray[3], 7); assert.sameValue(typedArray[5], undefined); + assert.sameValue(typedArray.constructor, TA); assert.sameValue(Object.getPrototypeOf(typedArray), TA.prototype); if (TA === Float32Array || TA === Float64Array) { diff --git a/test/built-ins/TypedArrays/object-argument-throws-from-property.js b/test/built-ins/TypedArrays/object-arg-throws-from-property.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-throws-from-property.js rename to test/built-ins/TypedArrays/object-arg-throws-from-property.js diff --git a/test/built-ins/TypedArrays/object-argument-throws-setting-property.js b/test/built-ins/TypedArrays/object-arg-throws-setting-property.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-throws-setting-property.js rename to test/built-ins/TypedArrays/object-arg-throws-setting-property.js diff --git a/test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js b/test/built-ins/TypedArrays/object-arg-throws-setting-symbol-property.js similarity index 100% rename from test/built-ins/TypedArrays/object-argument-throws-setting-symbol-property.js rename to test/built-ins/TypedArrays/object-arg-throws-setting-symbol-property.js diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js b/test/built-ins/TypedArrays/object-arg-undefined-newtarget-throws.js similarity index 100% rename from test/built-ins/TypedArrays/undefined-newtarget-invoked-with-object.js rename to test/built-ins/TypedArrays/object-arg-undefined-newtarget-throws.js diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js b/test/built-ins/TypedArrays/object-arg-use-custom-proto-if-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js rename to test/built-ins/TypedArrays/object-arg-use-custom-proto-if-object.js index 92c12d6f0f..1596d8d08e 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-object.js +++ b/test/built-ins/TypedArrays/object-arg-use-custom-proto-if-object.js @@ -42,5 +42,6 @@ newTarget.prototype = proto; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [], newTarget); + assert.sameValue(ta.constructor, Object); assert.sameValue(Object.getPrototypeOf(ta), proto); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/object-arg-use-default-proto-if-custom-proto-is-not-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js rename to test/built-ins/TypedArrays/object-arg-use-default-proto-if-custom-proto-is-not-object.js index b2adc26a1b..c8c7acfc42 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-object-argument-proto-is-not-object.js +++ b/test/built-ins/TypedArrays/object-arg-use-default-proto-if-custom-proto-is-not-object.js @@ -41,5 +41,6 @@ var o = []; testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [o], newTarget); + assert.sameValue(ta.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js b/test/built-ins/TypedArrays/typedarray-arg-custom-proto-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-returns-abrupt.js rename to test/built-ins/TypedArrays/typedarray-arg-custom-proto-access-throws.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-access-throws.js similarity index 98% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-access-throws.js index 59483279f8..06ccdda33d 100644 --- a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js +++ b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-access-throws.js @@ -30,7 +30,7 @@ testWithTypedArrayConstructors(function(TA) { var sample = new (TA === Int8Array ? sample2 : sample1); Object.defineProperty(sample.buffer, "constructor", { - get: function() { + get() { throw new Test262Error(); } }); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-custom-species.js similarity index 92% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-custom-species.js index 240a2b58c7..14436bf552 100644 --- a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-custom.js +++ b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-custom-species.js @@ -46,7 +46,7 @@ testWithTypedArrayConstructors(function(TA) { ctor[Symbol.species].prototype = custom; - var tarray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(tarray.buffer), custom); + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); assert.sameValue(called, 0); }); diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-not-object-throws.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-access-throws.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-not-ctor-throws.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-null.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-null.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-null.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-prototype-throws.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-buffer-ctor-species-undefined.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-buffer-ctor-species-undefined.js diff --git a/test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js b/test/built-ins/TypedArrays/typedarray-arg-other-ctor-returns-new-typedarray.js similarity index 100% rename from test/built-ins/TypedArrays/other-typedarray-ctor-argument-returns-new-typedarray.js rename to test/built-ins/TypedArrays/typedarray-arg-other-ctor-returns-new-typedarray.js diff --git a/test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js b/test/built-ins/TypedArrays/typedarray-arg-returns-new-instance.js similarity index 100% rename from test/built-ins/TypedArrays/called-with-typedarray-return-new-instance.js rename to test/built-ins/TypedArrays/typedarray-arg-returns-new-instance.js diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-access-throws.js similarity index 100% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-get-constructor.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-access-throws.js diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-custom.js similarity index 93% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-custom.js index 5189f01b20..09053c47d0 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-custom.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-custom.js @@ -54,7 +54,7 @@ testWithTypedArrayConstructors(function(TA) { ctor[Symbol.species].prototype = custom; - var tarray = new TA(sample); - assert.sameValue(Object.getPrototypeOf(tarray.buffer), custom); + var typedArray = new TA(sample); + assert.sameValue(Object.getPrototypeOf(typedArray.buffer), custom); assert.sameValue(called, 0); }); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js similarity index 96% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js index 1f0414068b..163c155e96 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-not-ctor.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-not-ctor.js @@ -37,11 +37,11 @@ features: [Symbol.species] testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var ctor = {}; - var o = { m() {} }; + var m = { m() {} }; sample.buffer.constructor = ctor; - ctor[Symbol.species] = o.m; + ctor[Symbol.species] = m; assert.throws(TypeError, function() { new TA(sample); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-null.js similarity index 100% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-null.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-null.js diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js similarity index 98% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js index 5eace03d87..fa60b0d58c 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-prototype-abrupt.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-prototype-throws.js @@ -51,7 +51,7 @@ testWithTypedArrayConstructors(function(TA) { ctor[Symbol.species] = function(){}.bind(null); Object.defineProperty(ctor[Symbol.species], "prototype", { - get: function() { + get() { throw new Test262Error(); } }); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-throws.js similarity index 98% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-throws.js index 04de7110ee..1ed0a51461 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-species.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-throws.js @@ -38,7 +38,7 @@ testWithTypedArrayConstructors(function(TA) { sample.buffer.constructor = ctor; Object.defineProperty(ctor, Symbol.species, { - get: function() { + get() { throw new Test262Error(); } }); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js similarity index 94% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js index e07620e5d1..4fbdb7dce4 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-ctor-species-undefined.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-species-undefined.js @@ -40,9 +40,9 @@ testWithTypedArrayConstructors(function(TA) { sample.buffer.constructor = ctor; ctor[Symbol.species] = undefined; - var a = new TA(sample); + var typedArray = new TA(sample); assert.sameValue( - Object.getPrototypeOf(a.buffer), + Object.getPrototypeOf(typedArray.buffer), ArrayBuffer.prototype, "buffer ctor is not called when species is undefined" ); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js similarity index 69% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js index f85aa5da7a..6309a97ef3 100644 --- a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-buffer-returns-abrupt-from-constructor-value.js +++ b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-buffer-ctor-value-not-obj-throws.js @@ -36,58 +36,29 @@ features: [Symbol] testWithTypedArrayConstructors(function(TA) { var sample = new TA(); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return 1; - }, - configurable: true - }); + sample.buffer.constructor = 1; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return true; - }, - configurable: true - }); - + sample.buffer.constructor = true; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return ''; - }, - configurable: true - }); - + sample.buffer.constructor = ''; assert.throws(TypeError, function() { new TA(sample); }); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return null; - }, - configurable: true - }); - + sample.buffer.constructor = null; assert.throws(TypeError, function() { new TA(sample); }); var s = Symbol('1'); - Object.defineProperty(sample.buffer, "constructor", { - get: function() { - return s; - }, - configurable: true - }); - + sample.buffer.constructor = s; assert.throws(TypeError, function() { new TA(sample); }); diff --git a/test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js b/test/built-ins/TypedArrays/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js similarity index 100% rename from test/built-ins/TypedArrays/same-typedarray-ctor-argument-returns-new-cloned-typedarray.js rename to test/built-ins/TypedArrays/typedarray-arg-same-ctor-returns-new-cloned-typedarray.js diff --git a/test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js b/test/built-ins/TypedArrays/typedarray-arg-undefined-newtarget-throws.js similarity index 100% rename from test/built-ins/TypedArrays/undefined-newtarget-invoked-with-typedarray.js rename to test/built-ins/TypedArrays/typedarray-arg-undefined-newtarget-throws.js diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js b/test/built-ins/TypedArrays/typedarray-arg-use-custom-proto-if-object.js similarity index 96% rename from test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js rename to test/built-ins/TypedArrays/typedarray-arg-use-custom-proto-if-object.js index 0aae23913b..9a558e875f 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-object.js +++ b/test/built-ins/TypedArrays/typedarray-arg-use-custom-proto-if-object.js @@ -43,5 +43,6 @@ var sample = new Int8Array(8); testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [sample], newTarget); + assert.sameValue(ta.constructor, Object); assert.sameValue(Object.getPrototypeOf(ta), proto); }); diff --git a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js b/test/built-ins/TypedArrays/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js similarity index 97% rename from test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js rename to test/built-ins/TypedArrays/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js index f9788039ce..f8248f39d8 100644 --- a/test/built-ins/TypedArrays/get-prototype-with-typedarray-argument-proto-is-not-object.js +++ b/test/built-ins/TypedArrays/typedarray-arg-use-default-proto-if-custom-proto-is-not-object.js @@ -41,5 +41,6 @@ var sample = new Int8Array(8); testWithTypedArrayConstructors(function(TA) { var ta = Reflect.construct(TA, [sample], newTarget); + assert.sameValue(ta.constructor, TA); assert.sameValue(Object.getPrototypeOf(ta), TA.prototype); }); From 75952beee22e1a3e6623889465f08eab749e0a19 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Fri, 5 Feb 2016 11:58:55 -0200 Subject: [PATCH 7/7] Move test file from TypedArray to TypedArrays folder --- .../buffer-arg-byteoffset-is-negative-zero.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/built-ins/{TypedArray/negative-zero-byteoffset.js => TypedArrays/buffer-arg-byteoffset-is-negative-zero.js} (100%) diff --git a/test/built-ins/TypedArray/negative-zero-byteoffset.js b/test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-zero.js similarity index 100% rename from test/built-ins/TypedArray/negative-zero-byteoffset.js rename to test/built-ins/TypedArrays/buffer-arg-byteoffset-is-negative-zero.js