From 6c5665897444b2b012957614ba30a082286e2f05 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Thu, 18 Feb 2016 15:21:20 -0500 Subject: [PATCH 1/3] Add tests for _TypedArray_.prototype methods --- .../TypedArrays/prototype/Symbol.iterator.js | 13 +++++++++++++ .../prototype/Symbol.toStringTag/inherited.js | 14 ++++++++++++++ .../TypedArrays/prototype/buffer/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/byteLength/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/byteOffset/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/copyWithin/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/entries/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/every/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/fill/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/filter/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/find/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/findIndex/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/forEach/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/indexOf/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/join/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/keys/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/lastIndexOf/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/length/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/map/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/reduce/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/reduceRight/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/reverse/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/set/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/slice/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/some/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/sort/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/subarray/inherited.js | 12 ++++++++++++ .../prototype/toLocaleString/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/toString/inherited.js | 12 ++++++++++++ .../TypedArrays/prototype/values/inherited.js | 12 ++++++++++++ 30 files changed, 363 insertions(+) create mode 100755 test/built-ins/TypedArrays/prototype/Symbol.iterator.js create mode 100644 test/built-ins/TypedArrays/prototype/Symbol.toStringTag/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/buffer/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/byteLength/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/byteOffset/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/copyWithin/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/entries/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/every/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/fill/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/filter/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/find/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/findIndex/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/forEach/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/indexOf/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/join/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/keys/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/lastIndexOf/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/length/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/map/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/reduce/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/reduceRight/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/reverse/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/set/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/slice/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/some/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/sort/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/subarray/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/toLocaleString/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/toString/inherited.js create mode 100644 test/built-ins/TypedArrays/prototype/values/inherited.js diff --git a/test/built-ins/TypedArrays/prototype/Symbol.iterator.js b/test/built-ins/TypedArrays/prototype/Symbol.iterator.js new file mode 100755 index 0000000000..cfb4a24244 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/Symbol.iterator.js @@ -0,0 +1,13 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype-@@iterator +description: > + _TypedArray_.prototype has no own property @@iterator +includes: [testTypedArray.js] +features: [Symbol.iterator] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty(Symbol.iterator), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/Symbol.toStringTag/inherited.js b/test/built-ins/TypedArrays/prototype/Symbol.toStringTag/inherited.js new file mode 100644 index 0000000000..1e5cc0e2bb --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/Symbol.toStringTag/inherited.js @@ -0,0 +1,14 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + _TypedArray_.prototype[@@toStringTag] is inherited from %TypedArray% + _TypedArray_.prototype has no own property @@toStringTag +includes: [testTypedArray.js] +features: [Symbol.toStringTag] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty(Symbol.toStringTag), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/buffer/inherited.js b/test/built-ins/TypedArrays/prototype/buffer/inherited.js new file mode 100644 index 0000000000..0d68c60fdc --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/buffer/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + _TypedArray_.prototype has no own property "buffer" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("buffer"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/byteLength/inherited.js b/test/built-ins/TypedArrays/prototype/byteLength/inherited.js new file mode 100644 index 0000000000..55646f37ef --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/byteLength/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + _TypedArray_.prototype has no own property "byteLength" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("byteLength"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/byteOffset/inherited.js b/test/built-ins/TypedArrays/prototype/byteOffset/inherited.js new file mode 100644 index 0000000000..eb098d6267 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/byteOffset/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + _TypedArray_.prototype has no own property "byteOffset" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("byteOffset"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/copyWithin/inherited.js b/test/built-ins/TypedArrays/prototype/copyWithin/inherited.js new file mode 100644 index 0000000000..9c2e52ac32 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/copyWithin/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + _TypedArray_.prototype has no own property "copyWithin" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("copyWithin"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/entries/inherited.js b/test/built-ins/TypedArrays/prototype/entries/inherited.js new file mode 100644 index 0000000000..e4b080c559 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/entries/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + _TypedArray_.prototype has no own property "entries" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("entries"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/every/inherited.js b/test/built-ins/TypedArrays/prototype/every/inherited.js new file mode 100644 index 0000000000..fcf42763ef --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/every/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.every +description: > + _TypedArray_.prototype has no own property "every" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("every"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/fill/inherited.js b/test/built-ins/TypedArrays/prototype/fill/inherited.js new file mode 100644 index 0000000000..050de1b053 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/fill/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + _TypedArray_.prototype has no own property "fill" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("fill"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/filter/inherited.js b/test/built-ins/TypedArrays/prototype/filter/inherited.js new file mode 100644 index 0000000000..48bde7b97a --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/filter/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + _TypedArray_.prototype has no own property "filter" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("filter"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/find/inherited.js b/test/built-ins/TypedArrays/prototype/find/inherited.js new file mode 100644 index 0000000000..39be0a7c7b --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/find/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.find +description: > + _TypedArray_.prototype has no own property "find" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("find"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/findIndex/inherited.js b/test/built-ins/TypedArrays/prototype/findIndex/inherited.js new file mode 100644 index 0000000000..df3acdd086 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/findIndex/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + _TypedArray_.prototype has no own property "findIndex" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("findIndex"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/forEach/inherited.js b/test/built-ins/TypedArrays/prototype/forEach/inherited.js new file mode 100644 index 0000000000..d08b41484b --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/forEach/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + _TypedArray_.prototype has no own property "forEach" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("forEach"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/indexOf/inherited.js b/test/built-ins/TypedArrays/prototype/indexOf/inherited.js new file mode 100644 index 0000000000..fdebbaed11 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/indexOf/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + _TypedArray_.prototype has no own property "indexOf" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("indexOf"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/join/inherited.js b/test/built-ins/TypedArrays/prototype/join/inherited.js new file mode 100644 index 0000000000..07db7980aa --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/join/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.join +description: > + _TypedArray_.prototype has no own property "join" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("join"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/keys/inherited.js b/test/built-ins/TypedArrays/prototype/keys/inherited.js new file mode 100644 index 0000000000..c2d85c011f --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/keys/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + _TypedArray_.prototype has no own property "keys" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("keys"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/lastIndexOf/inherited.js b/test/built-ins/TypedArrays/prototype/lastIndexOf/inherited.js new file mode 100644 index 0000000000..3dccc11ab7 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/lastIndexOf/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + _TypedArray_.prototype has no own property "lastIndexOf" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("lastIndexOf"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/length/inherited.js b/test/built-ins/TypedArrays/prototype/length/inherited.js new file mode 100644 index 0000000000..fb73a6d5ee --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/length/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + _TypedArray_.prototype has no own property "length" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("length"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/map/inherited.js b/test/built-ins/TypedArrays/prototype/map/inherited.js new file mode 100644 index 0000000000..8305e9331a --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/map/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.map +description: > + _TypedArray_.prototype has no own property "map" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("map"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/reduce/inherited.js b/test/built-ins/TypedArrays/prototype/reduce/inherited.js new file mode 100644 index 0000000000..a1327a87a2 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/reduce/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.reduce +description: > + _TypedArray_.prototype has no own property "reduce" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("reduce"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/reduceRight/inherited.js b/test/built-ins/TypedArrays/prototype/reduceRight/inherited.js new file mode 100644 index 0000000000..0073fd5d28 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/reduceRight/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + _TypedArray_.prototype has no own property "reduceRight" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("reduceRight"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/reverse/inherited.js b/test/built-ins/TypedArrays/prototype/reverse/inherited.js new file mode 100644 index 0000000000..54555621f7 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/reverse/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + _TypedArray_.prototype has no own property "reverse" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("reverse"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/set/inherited.js b/test/built-ins/TypedArrays/prototype/set/inherited.js new file mode 100644 index 0000000000..2b741bbdc9 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/set/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.set +description: > + _TypedArray_.prototype has no own property "set" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("set"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/slice/inherited.js b/test/built-ins/TypedArrays/prototype/slice/inherited.js new file mode 100644 index 0000000000..1fb88a8405 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/slice/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + _TypedArray_.prototype has no own property "slice" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("slice"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/some/inherited.js b/test/built-ins/TypedArrays/prototype/some/inherited.js new file mode 100644 index 0000000000..5d3bf013d8 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/some/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.some +description: > + _TypedArray_.prototype has no own property "some" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("some"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/sort/inherited.js b/test/built-ins/TypedArrays/prototype/sort/inherited.js new file mode 100644 index 0000000000..b638661112 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/sort/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + _TypedArray_.prototype has no own property "sort" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("sort"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/subarray/inherited.js b/test/built-ins/TypedArrays/prototype/subarray/inherited.js new file mode 100644 index 0000000000..53bb41efce --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/subarray/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + _TypedArray_.prototype has no own property "subarray" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("subarray"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/toLocaleString/inherited.js b/test/built-ins/TypedArrays/prototype/toLocaleString/inherited.js new file mode 100644 index 0000000000..69809cf7db --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/toLocaleString/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + _TypedArray_.prototype has no own property "toLocaleString" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("toLocaleString"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/toString/inherited.js b/test/built-ins/TypedArrays/prototype/toString/inherited.js new file mode 100644 index 0000000000..44cb7c19bc --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/toString/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.tostring +description: > + _TypedArray_.prototype has no own property "toString" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("toString"), false); +}); diff --git a/test/built-ins/TypedArrays/prototype/values/inherited.js b/test/built-ins/TypedArrays/prototype/values/inherited.js new file mode 100644 index 0000000000..86570c55a0 --- /dev/null +++ b/test/built-ins/TypedArrays/prototype/values/inherited.js @@ -0,0 +1,12 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.values +description: > + _TypedArray_.prototype has no own property "values" +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + assert.sameValue(TA.prototype.hasOwnProperty("values"), false); +}); From 02cdfacd31442d32ff81aecf725f2f2ccd66a92b Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Mon, 22 Feb 2016 13:44:39 -0500 Subject: [PATCH 2/3] Add tests for %TypedArray%.prototype get methods Includes buffer, byteLength, byteOffset, length, and @@toStringTag --- .../return-typedarrayname.js | 21 ++++++++ .../this-has-no-typedarrayname-internal.js | 29 +++++++++++ .../Symbol.toStringTag/this-is-not-object.js | 27 +++++++++++ .../prototype/buffer/return-buffer.js | 21 ++++++++ .../buffer/return-dataview-buffer.js | 24 ++++++++++ .../this-has-no-viewedarraybuffer-internal.js | 35 ++++++++++++++ .../prototype/buffer/this-is-not-object.js | 48 +++++++++++++++++++ .../prototype/byteLength/return-bytelength.js | 23 +++++++++ .../byteLength/return-dataview-bytelength.js | 24 ++++++++++ .../this-has-no-viewedarraybuffer-internal.js | 35 ++++++++++++++ .../byteLength/this-is-not-object.js | 48 +++++++++++++++++++ .../prototype/byteOffset/return-byteoffset.js | 30 ++++++++++++ .../byteOffset/return-dataview-byteoffset.js | 27 +++++++++++ .../this-has-no-viewedarraybuffer-internal.js | 35 ++++++++++++++ .../byteOffset/this-is-not-object.js | 48 +++++++++++++++++++ .../prototype/length/return-length.js | 27 +++++++++++ .../this-has-no-typedarrayname-internal.js | 41 ++++++++++++++++ .../length/this-is-not-object-strict-mode.js | 27 +++++++++++ .../prototype/length/this-is-not-object.js | 40 ++++++++++++++++ 19 files changed, 610 insertions(+) create mode 100644 test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js create mode 100644 test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js create mode 100644 test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js create mode 100644 test/built-ins/TypedArray/prototype/buffer/return-buffer.js create mode 100644 test/built-ins/TypedArray/prototype/buffer/return-dataview-buffer.js create mode 100644 test/built-ins/TypedArray/prototype/buffer/this-has-no-viewedarraybuffer-internal.js create mode 100644 test/built-ins/TypedArray/prototype/buffer/this-is-not-object.js create mode 100644 test/built-ins/TypedArray/prototype/byteLength/return-bytelength.js create mode 100644 test/built-ins/TypedArray/prototype/byteLength/return-dataview-bytelength.js create mode 100644 test/built-ins/TypedArray/prototype/byteLength/this-has-no-viewedarraybuffer-internal.js create mode 100644 test/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js create mode 100644 test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js create mode 100644 test/built-ins/TypedArray/prototype/byteOffset/return-dataview-byteoffset.js create mode 100644 test/built-ins/TypedArray/prototype/byteOffset/this-has-no-viewedarraybuffer-internal.js create mode 100644 test/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js create mode 100644 test/built-ins/TypedArray/prototype/length/return-length.js create mode 100644 test/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js create mode 100644 test/built-ins/TypedArray/prototype/length/this-is-not-object-strict-mode.js create mode 100644 test/built-ins/TypedArray/prototype/length/this-is-not-object.js diff --git a/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js new file mode 100644 index 0000000000..72127f90d2 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: | + Return value from the [[TypedArrayName]] internal slot +info: > + 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ] + + ... + 4. Let name be the value of O's [[TypedArrayName]] internal slot. + 5. Assert: name is a String value. + 6. Return name. +includes: [testTypedArray.js] +features: [Symbol.toStringTag] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var ta = new TA(); + assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); +}); diff --git a/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js new file mode 100644 index 0000000000..6c6567b824 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.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. +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return undefined when `this` does not have a [[TypedArrayName]] internal slot +info: > + 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol.toStringTag, DataView] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call({}), undefined); +assert.sameValue(getter.call([]), undefined); +assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); + +var ab = new ArrayBuffer(8); +var dv = new DataView(ab, 0, 1); +assert.sameValue(getter.call(dv), undefined); diff --git a/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js new file mode 100644 index 0000000000..99a95d608b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.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. +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: Return undefined when `this` is not Object +info: > + 22.2.3.32 get %TypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + 2. If Type(O) is not Object, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol, Symbol.toStringTag] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call(undefined), undefined, "this is undefined"); +assert.sameValue(getter.call(42), undefined, "this is 42"); +assert.sameValue(getter.call("foo"), undefined, "this is a string"); +assert.sameValue(getter.call(true), undefined, "this is true"); +assert.sameValue(getter.call(false), undefined, "this is false"); +assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol"); +assert.sameValue(getter.call(null), undefined, "this is null"); diff --git a/test/built-ins/TypedArray/prototype/buffer/return-buffer.js b/test/built-ins/TypedArray/prototype/buffer/return-buffer.js new file mode 100644 index 0000000000..63e3b07139 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/buffer/return-buffer.js @@ -0,0 +1,21 @@ +// 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.3.1 +description: | + Return buffer from [[ViewedArrayBuffer]] internal slot +info: > + 22.2.3.1 get %TypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); + var ta = new TA(buffer); + + assert.sameValue(ta.buffer, buffer); +}); diff --git a/test/built-ins/TypedArray/prototype/buffer/return-dataview-buffer.js b/test/built-ins/TypedArray/prototype/buffer/return-dataview-buffer.js new file mode 100644 index 0000000000..05992e520e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/buffer/return-dataview-buffer.js @@ -0,0 +1,24 @@ +// 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.3.1 +description: | + Return buffer from DataView's instance [[ViewedArrayBuffer]] internal slot +info: > + 22.2.3.1 get %TypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testTypedArray.js] +features: [DataView] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + TypedArray.prototype, "buffer" +).get; + +var buffer = new ArrayBuffer(8); +var dv = new DataView(buffer, 0); + +assert.sameValue(getter.call(dv), buffer); diff --git a/test/built-ins/TypedArray/prototype/buffer/this-has-no-viewedarraybuffer-internal.js b/test/built-ins/TypedArray/prototype/buffer/this-has-no-viewedarraybuffer-internal.js new file mode 100644 index 0000000000..8939cad810 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/buffer/this-has-no-viewedarraybuffer-internal.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. +/*--- +es6id: 22.2.3.1 +description: | + Throws a TypeError exception when `this` does not have a [[ViewedArrayBuffer]] + internal slot +info: > + 22.2.3.1 get %TypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "buffer" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); diff --git a/test/built-ins/TypedArray/prototype/buffer/this-is-not-object.js b/test/built-ins/TypedArray/prototype/buffer/this-is-not-object.js new file mode 100644 index 0000000000..b0cdaf828a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/buffer/this-is-not-object.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. +/*--- +es6id: 22.2.3.1 +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.1 get %TypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "buffer" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/byteLength/return-bytelength.js b/test/built-ins/TypedArray/prototype/byteLength/return-bytelength.js new file mode 100644 index 0000000000..45ac33ac41 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/return-bytelength.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. +/*--- +es6id: 22.2.3.2 +description: | + Return value from [[ByteLength]] internal slot +info: > + 22.2.3.2 get %TypedArray%.prototype.byteLength + + ... + 6. Let size be the value of O's [[ByteLength]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var bytesPerElement = TA.BYTES_PER_ELEMENT; + var ta1 = new TA(); + assert.sameValue(ta1.byteLength, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.byteLength, 42 * bytesPerElement); +}); diff --git a/test/built-ins/TypedArray/prototype/byteLength/return-dataview-bytelength.js b/test/built-ins/TypedArray/prototype/byteLength/return-dataview-bytelength.js new file mode 100644 index 0000000000..8f1930d0d0 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/return-dataview-bytelength.js @@ -0,0 +1,24 @@ +// 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.3.2 +description: | + Return buffer from DataView's instance [[ViewedArrayBuffer]] internal slot +info: > + 22.2.3.2 get %TypedArray%.prototype.byteLength + + ... + 6. Let size be the value of O's [[ByteLength]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +features: [DataView] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + TypedArray.prototype, "byteLength" +).get; + +var buffer = new ArrayBuffer(64); +var dv = new DataView(buffer, 0); + +assert.sameValue(getter.call(dv), 64); diff --git a/test/built-ins/TypedArray/prototype/byteLength/this-has-no-viewedarraybuffer-internal.js b/test/built-ins/TypedArray/prototype/byteLength/this-has-no-viewedarraybuffer-internal.js new file mode 100644 index 0000000000..935c86c03d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/this-has-no-viewedarraybuffer-internal.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. +/*--- +es6id: 22.2.3.2 +description: | + Throws a TypeError exception when `this` does not have a [[ViewedArrayBuffer]] + internal slot +info: > + 22.2.3.2 get %TypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); diff --git a/test/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js b/test/built-ins/TypedArray/prototype/byteLength/this-is-not-object.js new file mode 100644 index 0000000000..8dd7a61798 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteLength/this-is-not-object.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. +/*--- +es6id: 22.2.3.2 +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.2 get %TypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js b/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.js new file mode 100644 index 0000000000..51570aa23a --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/return-byteoffset.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. +/*--- +es6id: 22.2.3.3 +description: | + Return value from [[ByteOffset]] internal slot +info: > + 22.2.3.3 get %TypedArray%.prototype.byteOffset + + ... + 6. Let offset be the value of O's [[ByteOffset]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); + + var offset = 4 * TA.BYTES_PER_ELEMENT; + + var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var ta2 = new TA(buffer1, offset); + assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); + + var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var sample = new TA(buffer2, offset) + var ta3 = new TA(sample); + assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); +}); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/return-dataview-byteoffset.js b/test/built-ins/TypedArray/prototype/byteOffset/return-dataview-byteoffset.js new file mode 100644 index 0000000000..916514a5c5 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/return-dataview-byteoffset.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. +/*--- +es6id: 22.2.3.2 +description: | + Return buffer from DataView's instance [[ViewedArrayBuffer]] internal slot +info: > + 22.2.3.2 get %TypedArray%.prototype.byteOffset + + ... + 6. Let offset be the value of O's [[ByteOffset]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +features: [DataView] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + TypedArray.prototype, "byteOffset" +).get; + +var buffer = new ArrayBuffer(64); + +var dv1 = new DataView(buffer, 0); +assert.sameValue(getter.call(dv1), 0); + +var dv2 = new DataView(buffer, 32); +assert.sameValue(getter.call(dv2), 32); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/this-has-no-viewedarraybuffer-internal.js b/test/built-ins/TypedArray/prototype/byteOffset/this-has-no-viewedarraybuffer-internal.js new file mode 100644 index 0000000000..a444fdbf14 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/this-has-no-viewedarraybuffer-internal.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. +/*--- +es6id: 22.2.3.3 +description: | + Throws a TypeError exception when `this` does not have a [[ViewedArrayBuffer]] + internal slot +info: > + 22.2.3.3 get %TypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "byteOffset" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js b/test/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.js new file mode 100644 index 0000000000..244072f9fa --- /dev/null +++ b/test/built-ins/TypedArray/prototype/byteOffset/this-is-not-object.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. +/*--- +es6id: 22.2.3.3 +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.3 get %TypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "byteOffset" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/length/return-length.js b/test/built-ins/TypedArray/prototype/length/return-length.js new file mode 100644 index 0000000000..61e3f9dfcb --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/return-length.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. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + Return value from the [[ArrayLength]] internal slot +info: > + 22.2.3.18 get %TypedArray%.prototype.length + + ... + 6. Let length be the value of O's [[ArrayLength]] internal slot. + 7. Return length. + + --- + + The current tests on `prop-desc.js` and `length.js` already assert `length` is + not a dynamic property as in regular arrays. +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.length, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.length, 42); +}); diff --git a/test/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/test/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js new file mode 100644 index 0000000000..94db7aa579 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.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. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: > + 22.2.3.18 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [DataView] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "length" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/built-ins/TypedArray/prototype/length/this-is-not-object-strict-mode.js b/test/built-ins/TypedArray/prototype/length/this-is-not-object-strict-mode.js new file mode 100644 index 0000000000..d22f4d5ad7 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/this-is-not-object-strict-mode.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. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when `this` is null or undefined +info: > + 22.2.3.18 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +flags: [onlyStrict] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "length" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}); + +assert.throws(TypeError, function() { + getter.call(null); +}); diff --git a/test/built-ins/TypedArray/prototype/length/this-is-not-object.js b/test/built-ins/TypedArray/prototype/length/this-is-not-object.js new file mode 100644 index 0000000000..77685b43a1 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/length/this-is-not-object.js @@ -0,0 +1,40 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.18 get %TypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + TypedArrayPrototype, "length" +).get; + +assert.throws(TypeError, function() { + getter.call(42); +}); + +assert.throws(TypeError, function() { + getter.call("1"); +}); + +assert.throws(TypeError, function() { + getter.call(true); +}); + +assert.throws(TypeError, function() { + getter.call(false); +}); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}); From 7445d77d6d6b81dd92bc0f9a9f0e25a12b511e0e Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Tue, 23 Feb 2016 13:50:13 -0500 Subject: [PATCH 3/3] Update descriptor tests for %TypedArray%.prototype properties --- .../TypedArray/prototype/buffer/prop-desc.js | 12 +++++++++--- .../prototype/byteLength/prop-desc.js | 12 +++++++++--- .../prototype/byteOffset/prop-desc.js | 12 +++++++++--- .../TypedArray/prototype/length/prop-desc.js | 12 +++++++++--- .../prototype/toString/prop-desc.js | 19 +++++++++++++++++++ 5 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 test/built-ins/TypedArray/prototype/toString/prop-desc.js diff --git a/test/built-ins/TypedArray/prototype/buffer/prop-desc.js b/test/built-ins/TypedArray/prototype/buffer/prop-desc.js index a413419495..f026c0668e 100644 --- a/test/built-ins/TypedArray/prototype/buffer/prop-desc.js +++ b/test/built-ins/TypedArray/prototype/buffer/prop-desc.js @@ -7,11 +7,17 @@ description: > info: > %TypedArray%.prototype.buffer is an accessor property whose set accessor function is undefined. -includes: [testTypedArray.js] + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] ---*/ var TypedArrayPrototype = TypedArray.prototype; -var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, 'buffer'); +var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "buffer"); assert.sameValue(desc.set, undefined); -assert.sameValue(typeof desc.get, 'function'); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(TypedArrayPrototype, "buffer"); +verifyConfigurable(TypedArrayPrototype, "buffer"); diff --git a/test/built-ins/TypedArray/prototype/byteLength/prop-desc.js b/test/built-ins/TypedArray/prototype/byteLength/prop-desc.js index 8ceec38253..3f227ee448 100644 --- a/test/built-ins/TypedArray/prototype/byteLength/prop-desc.js +++ b/test/built-ins/TypedArray/prototype/byteLength/prop-desc.js @@ -7,11 +7,17 @@ description: > info: > %TypedArray%.prototype.byteLength is an accessor property whose set accessor function is undefined. -includes: [testTypedArray.js] + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] ---*/ var TypedArrayPrototype = TypedArray.prototype; -var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, 'byteLength'); +var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "byteLength"); assert.sameValue(desc.set, undefined); -assert.sameValue(typeof desc.get, 'function'); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(TypedArrayPrototype, "byteLength"); +verifyConfigurable(TypedArrayPrototype, "byteLength"); diff --git a/test/built-ins/TypedArray/prototype/byteOffset/prop-desc.js b/test/built-ins/TypedArray/prototype/byteOffset/prop-desc.js index 7b180db704..f03c4963d6 100644 --- a/test/built-ins/TypedArray/prototype/byteOffset/prop-desc.js +++ b/test/built-ins/TypedArray/prototype/byteOffset/prop-desc.js @@ -7,11 +7,17 @@ description: > info: > %TypedArray%.prototype.byteOffset is an accessor property whose set accessor function is undefined. -includes: [testTypedArray.js] + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] ---*/ var TypedArrayPrototype = TypedArray.prototype; -var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, 'byteOffset'); +var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "byteOffset"); assert.sameValue(desc.set, undefined); -assert.sameValue(typeof desc.get, 'function'); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(TypedArrayPrototype, "byteOffset"); +verifyConfigurable(TypedArrayPrototype, "byteOffset"); diff --git a/test/built-ins/TypedArray/prototype/length/prop-desc.js b/test/built-ins/TypedArray/prototype/length/prop-desc.js index 3f40eae893..ff2718060b 100644 --- a/test/built-ins/TypedArray/prototype/length/prop-desc.js +++ b/test/built-ins/TypedArray/prototype/length/prop-desc.js @@ -7,11 +7,17 @@ description: > info: > %TypedArray%.prototype.length is an accessor property whose set accessor function is undefined. -includes: [testTypedArray.js] + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] ---*/ var TypedArrayPrototype = TypedArray.prototype; -var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, 'length'); +var desc = Object.getOwnPropertyDescriptor(TypedArrayPrototype, "length"); assert.sameValue(desc.set, undefined); -assert.sameValue(typeof desc.get, 'function'); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(TypedArrayPrototype, "length"); +verifyConfigurable(TypedArrayPrototype, "length"); diff --git a/test/built-ins/TypedArray/prototype/toString/prop-desc.js b/test/built-ins/TypedArray/prototype/toString/prop-desc.js new file mode 100644 index 0000000000..c5277b1477 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toString/prop-desc.js @@ -0,0 +1,19 @@ +// 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.3.28 +esid: sec-%typedarray%.prototype.tostring +description: > + "String" property of TypedArrayPrototype +info: > + ES6 section 17: Every other data property described in clauses 18 through + 26 and in Annex B.2 has the attributes { [[Writable]]: true, + [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js, testTypedArray.js] +---*/ + +var TypedArrayPrototype = TypedArray.prototype; + +verifyNotEnumerable(TypedArrayPrototype, "toString"); +verifyWritable(TypedArrayPrototype, "toString"); +verifyConfigurable(TypedArrayPrototype, "toString");