diff --git a/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js b/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..144ebf80e36a9d8018fa89e2566a2496b3a7d9e2 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var copyWithin = TypedArray.prototype.copyWithin; + +assert.throws(TypeError, function() { + copyWithin.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + copyWithin.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + copyWithin.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + copyWithin.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + copyWithin.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + copyWithin.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + copyWithin.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..f18aa5056901f1bfd884b711b3505dc272c19082 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.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-%typedarray%.prototype.copywithin +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.5 %TypedArray%.prototype.copyWithin (target, start [ , end ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var copyWithin = TypedArray.prototype.copyWithin; + +assert.throws(TypeError, function() { + copyWithin.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + copyWithin.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + copyWithin.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + copyWithin.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/entries/this-is-not-object.js b/test/built-ins/TypedArray/prototype/entries/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..5ba61ff2c43fe8da5c9b25ef1ddece3ef523e18c --- /dev/null +++ b/test/built-ins/TypedArray/prototype/entries/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.entries +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.6 %TypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var entries = TypedArray.prototype.entries; + +assert.throws(TypeError, function() { + entries.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + entries.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + entries.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + entries.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + entries.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + entries.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + entries.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..6ce13bd804a4aba80d8b076dc5421d804d6ceb46 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.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. +/*--- +esid: sec-%typedarray%.prototype.entries +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.6 %TypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var entries = TypedArray.prototype.entries; + +assert.throws(TypeError, function() { + entries.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + entries.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + entries.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + entries.call(dv); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/every/this-is-not-object.js b/test/built-ins/TypedArray/prototype/every/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..9cb64b5d8fea0f3709b58b0f31e49c81c6f81cc7 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/every/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var every = TypedArray.prototype.every; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + every.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + every.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + every.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + every.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + every.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + every.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + every.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..7d4d1d83d3bda9cfe2198203d6589dc164054803 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.every +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.7 %TypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var every = TypedArray.prototype.every; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + every.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + every.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + every.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + every.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/fill/this-is-not-object.js b/test/built-ins/TypedArray/prototype/fill/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..0655e6d3836ad805a511474471284665ebbd9ff1 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var fill = TypedArray.prototype.fill; + +assert.throws(TypeError, function() { + fill.call(undefined, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + fill.call(null, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + fill.call(42, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + fill.call("1", 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + fill.call(true, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + fill.call(false, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + fill.call(s, 0); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..1656ee3da960592de6d9aefbfb5aed02258ab14d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.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-%typedarray%.prototype.fill +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.8 %TypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var fill = TypedArray.prototype.fill; + +assert.throws(TypeError, function() { + fill.call({}, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + fill.call([], 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + fill.call(ab, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + fill.call(dv, 0); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/filter/this-is-not-object.js b/test/built-ins/TypedArray/prototype/filter/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..c44148f65870740ef0690cca585da1a0a231ab4e --- /dev/null +++ b/test/built-ins/TypedArray/prototype/filter/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var filter = TypedArray.prototype.filter; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + filter.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + filter.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + filter.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + filter.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + filter.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + filter.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + filter.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..7013503a8cf38231980d00d85cd0cf6c65cba716 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -0,0 +1,44 @@ +// 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: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.9 %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var filter = TypedArray.prototype.filter; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + filter.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + filter.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + filter.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + filter.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/find/this-is-not-object.js b/test/built-ins/TypedArray/prototype/find/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..dcbc17fc16f0772cd415b0ef05b3c23d0b961fdd --- /dev/null +++ b/test/built-ins/TypedArray/prototype/find/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var find = TypedArray.prototype.find; +var predicate = function() {}; + +assert.throws(TypeError, function() { + find.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + find.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + find.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + find.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + find.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + find.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + find.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..a5197d692b6794f06573d1c46c7bd8085f7780f1 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.find +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.10 %TypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var find = TypedArray.prototype.find; +var predicate = function() {}; + +assert.throws(TypeError, function() { + find.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + find.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + find.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + find.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js b/test/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..389c5981fe42be9d595a41cd67480804313be1a8 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var findIndex = TypedArray.prototype.findIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findIndex.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + findIndex.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + findIndex.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + findIndex.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + findIndex.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + findIndex.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + findIndex.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..2847e0c5db257d77111084b4b501f44961dcf486 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.findindex +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.11 %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var findIndex = TypedArray.prototype.findIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findIndex.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + findIndex.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + findIndex.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + findIndex.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/forEach/this-is-not-object.js b/test/built-ins/TypedArray/prototype/forEach/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..9fcfbbdc36f80203c5ec92c42e985c530de33046 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/forEach/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var forEach = TypedArray.prototype.forEach; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + forEach.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + forEach.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + forEach.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + forEach.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + forEach.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + forEach.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + forEach.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..f01f21ec1864919f7b4d98c184a3171aa22b1ede --- /dev/null +++ b/test/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.foreach +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.12 %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var forEach = TypedArray.prototype.forEach; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + forEach.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + forEach.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + forEach.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + forEach.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/includes/this-is-not-object.js b/test/built-ins/TypedArray/prototype/includes/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..15e220b561f5ad9df20367fd77327c8f0d2ed59f --- /dev/null +++ b/test/built-ins/TypedArray/prototype/includes/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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.14 +esid: sec-%typedarray%.prototype.includes +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var includes = TypedArray.prototype.includes; + +assert.throws(TypeError, function() { + includes.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + includes.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + includes.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + includes.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + includes.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + includes.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + includes.call(s, 42); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..c9a8e04f4b60feaef50a2dde1ce7359462ca47e4 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.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-%typedarray%.prototype.includes +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.14 %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var includes = TypedArray.prototype.includes; + +assert.throws(TypeError, function() { + includes.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + includes.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + includes.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + includes.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js b/test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..bca272e38cd5ac301c836c8d6c1e42e03e319f2d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var indexOf = TypedArray.prototype.indexOf; + +assert.throws(TypeError, function() { + indexOf.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + indexOf.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + indexOf.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + indexOf.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + indexOf.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + indexOf.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + indexOf.call(s, 42); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..d2e705173d38f68a20df967238620c63c298304d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.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-%typedarray%.prototype.indexof +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.13 %TypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var indexOf = TypedArray.prototype.indexOf; + +assert.throws(TypeError, function() { + indexOf.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + indexOf.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + indexOf.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + indexOf.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/join/this-is-not-object.js b/test/built-ins/TypedArray/prototype/join/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..f9dc5f699ce884068ba5c74a21833e3ca6e0bdff --- /dev/null +++ b/test/built-ins/TypedArray/prototype/join/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.join +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.15 %TypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var join = TypedArray.prototype.join; + +assert.throws(TypeError, function() { + join.call(undefined, ""); +}, "this is undefined"); + +assert.throws(TypeError, function() { + join.call(null, ""); +}, "this is null"); + +assert.throws(TypeError, function() { + join.call(42, ""); +}, "this is 42"); + +assert.throws(TypeError, function() { + join.call("1", ""); +}, "this is a string"); + +assert.throws(TypeError, function() { + join.call(true, ""); +}, "this is true"); + +assert.throws(TypeError, function() { + join.call(false, ""); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + join.call(s, ""); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..8087d3fa83e3bd385f82ea633d21c0a7a0e3da19 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.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-%typedarray%.prototype.join +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.15 %TypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var join = TypedArray.prototype.join; + +assert.throws(TypeError, function() { + join.call({}, ""); +}, "this is an Object"); + +assert.throws(TypeError, function() { + join.call([], ""); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + join.call(ab, ""); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + join.call(dv, ""); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/keys/this-is-not-object.js b/test/built-ins/TypedArray/prototype/keys/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..fa71ae3b3496bee237f2daeab9241684f773339b --- /dev/null +++ b/test/built-ins/TypedArray/prototype/keys/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.keys +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.16 %TypedArray%.prototype.keys ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var keys = TypedArray.prototype.keys; + +assert.throws(TypeError, function() { + keys.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + keys.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + keys.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + keys.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + keys.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + keys.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + keys.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..327beeb42822f7395ec9293b1da4542df377661d --- /dev/null +++ b/test/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.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. +/*--- +esid: sec-%typedarray%.prototype.keys +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.16 %TypedArray%.prototype.keys ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var keys = TypedArray.prototype.keys; + +assert.throws(TypeError, function() { + keys.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + keys.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + keys.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + keys.call(dv); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..0e8863374beba39de74ea8b03698bee2f49882a9 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var lastIndexOf = TypedArray.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + lastIndexOf.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + lastIndexOf.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + lastIndexOf.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + lastIndexOf.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + lastIndexOf.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + lastIndexOf.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + lastIndexOf.call(s, 42); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..892529b76ceeac7457919abc4474eef99af16943 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.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-%typedarray%.prototype.lastindexof +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.17 %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var lastIndexOf = TypedArray.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + lastIndexOf.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + lastIndexOf.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + lastIndexOf.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + lastIndexOf.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/map/this-is-not-object.js b/test/built-ins/TypedArray/prototype/map/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..baa0a792371f12f1e3148d1714f0d9018d2e9265 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/map/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var map = TypedArray.prototype.map; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + map.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + map.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + map.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + map.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + map.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + map.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + map.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..17e98d52e01e7b74e97d3e5da5cedafdf434aae1 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.map +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.19 %TypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var map = TypedArray.prototype.map; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + map.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + map.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + map.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + map.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/reduce/this-is-not-object.js b/test/built-ins/TypedArray/prototype/reduce/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..4f1280bede174db291cd1748bf5ab1364c5c67fe --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduce/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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.reduce +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var reduce = TypedArray.prototype.reduce; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduce.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reduce.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + reduce.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + reduce.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + reduce.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + reduce.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reduce.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..46cc4434ddab2ac6b48d57ba0d8d64a040d31248 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reduce +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.20 %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var reduce = TypedArray.prototype.reduce; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduce.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reduce.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reduce.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reduce.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js b/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..376465de3119dfa7edb9390624cd96f353f8745f --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var reduceRight = TypedArray.prototype.reduceRight; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduceRight.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reduceRight.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + reduceRight.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + reduceRight.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + reduceRight.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + reduceRight.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reduceRight.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..942007ca8cd76bcd1186f450612a56eafa5ba546 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.21 %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var reduceRight = TypedArray.prototype.reduceRight; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduceRight.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reduceRight.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reduceRight.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reduceRight.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/reverse/this-is-not-object.js b/test/built-ins/TypedArray/prototype/reverse/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..0185851b9363a0269061e57710b03021065b2312 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reverse/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.22 %TypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var reverse = TypedArray.prototype.reverse; + +assert.throws(TypeError, function() { + reverse.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reverse.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + reverse.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + reverse.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + reverse.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + reverse.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reverse.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..7716cdabeebb42f499b5a1d5b47f75cc70ebf521 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.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-%typedarray%.prototype.reverse +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.22 %TypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var reverse = TypedArray.prototype.reverse; + +assert.throws(TypeError, function() { + reverse.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reverse.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reverse.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reverse.call(dv); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/set/this-is-not-object.js b/test/built-ins/TypedArray/prototype/set/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..db5e53dc2addb91ed3c974e4da29c27013aff0a8 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/set/this-is-not-object.js @@ -0,0 +1,75 @@ +// 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-overloaded-offset +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.23 %TypedArray%.prototype.set + + ... + 2. Let target be the this value. + 3. If Type(target) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var set = TypedArray.prototype.set; + +assert.throws(TypeError, function() { + set.call(undefined, []); +}, "this is undefined"); + +assert.throws(TypeError, function() { + set.call(null, []); +}, "this is null"); + +assert.throws(TypeError, function() { + set.call(undefined, new Int8Array()); +}, "this is undefined"); + +assert.throws(TypeError, function() { + set.call(null, new Int8Array()); +}, "this is null"); + +assert.throws(TypeError, function() { + set.call(42, []); +}, "this is 42"); + +assert.throws(TypeError, function() { + set.call("1", []); +}, "this is a string"); + +assert.throws(TypeError, function() { + set.call(true, []); +}, "this is true"); + +assert.throws(TypeError, function() { + set.call(false, []); +}, "this is false"); + +var s1 = Symbol("s"); +assert.throws(TypeError, function() { + set.call(s1, []); +}, "this is a Symbol"); + +assert.throws(TypeError, function() { + set.call(42, new Int8Array(1)); +}, "this is 42"); + +assert.throws(TypeError, function() { + set.call("1", new Int8Array(1)); +}, "this is a string"); + +assert.throws(TypeError, function() { + set.call(true, new Int8Array(1)); +}, "this is true"); + +assert.throws(TypeError, function() { + set.call(false, new Int8Array(1)); +}, "this is false"); + +var s2 = Symbol("s"); +assert.throws(TypeError, function() { + set.call(s2, new Int8Array(1)); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..4cd2a86c7eb94876445c6b732c35df09cdf0ec70 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +// 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-overloaded-offset +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.23 %TypedArray%.prototype.set + + ... + 2. Let target be the this value. + 3. If Type(target) is not Object, throw a TypeError exception. + 4. If target does not have a [[TypedArrayName]] internal slot, throw a + TypeError exception. + ... +includes: [testTypedArray.js] +---*/ + +var set = TypedArray.prototype.set; + +assert.throws(TypeError, function() { + set.call({}, []); +}, "this is an Object"); + +assert.throws(TypeError, function() { + set.call([], []); +}, "this is an Array"); + +var ab1 = new ArrayBuffer(8); +assert.throws(TypeError, function() { + set.call(ab1, []); +}, "this is an ArrayBuffer instance"); + +var dv1 = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + set.call(dv1, []); +}, "this is a DataView instance"); + +assert.throws(TypeError, function() { + set.call({}, new Int8Array()); +}, "this is an Object"); + +assert.throws(TypeError, function() { + set.call([], new Int8Array()); +}, "this is an Array"); + +var ab2 = new ArrayBuffer(8); +assert.throws(TypeError, function() { + set.call(ab2, new Int8Array()); +}, "this is an ArrayBuffer instance"); + +var dv2 = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + set.call(dv2, new Int8Array()); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/slice/this-is-not-object.js b/test/built-ins/TypedArray/prototype/slice/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..b1ac94603b82e3a500dcc8be891ee4ace9ec4749 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/slice/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.24 %TypedArray%.prototype.slice ( start, end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var slice = TypedArray.prototype.slice; + +assert.throws(TypeError, function() { + slice.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + slice.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + slice.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + slice.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + slice.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + slice.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + slice.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..3c818d5df6bf1f33dba4d93e7286d6ccdc5ba716 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.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. +/*--- +esid: sec-%typedarray%.prototype.slice +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.24 %TypedArray%.prototype.slice ( start, end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var slice = TypedArray.prototype.slice; + +assert.throws(TypeError, function() { + slice.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + slice.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + slice.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + slice.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/some/this-is-not-object.js b/test/built-ins/TypedArray/prototype/some/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..35fa6c68b4126b62d0057cb1cb679672b8205ecd --- /dev/null +++ b/test/built-ins/TypedArray/prototype/some/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var some = TypedArray.prototype.some; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + some.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + some.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + some.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + some.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + some.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + some.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + some.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..ba48c8beb9441b671481dfce465326721e3d3845 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.some +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.25 %TypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var some = TypedArray.prototype.some; +var callbackfn = function () {}; + +assert.throws(TypeError, function() { + some.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + some.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + some.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + some.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/sort/this-is-not-object.js b/test/built-ins/TypedArray/prototype/sort/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..f60cf4664ed6dd90850ff88d749b9ed8c4276166 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/sort/this-is-not-object.js @@ -0,0 +1,51 @@ +// 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: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.26 %TypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value as the argument. + 2. Let buffer be ? ValidateTypedArray(obj). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var sort = TypedArray.prototype.sort; +var comparefn = function() {}; + +assert.throws(TypeError, function() { + sort.call(undefined, comparefn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + sort.call(null, comparefn); +}, "this is null"); + +assert.throws(TypeError, function() { + sort.call(42, comparefn); +}, "this is 42"); + +assert.throws(TypeError, function() { + sort.call("1", comparefn); +}, "this is a string"); + +assert.throws(TypeError, function() { + sort.call(true, comparefn); +}, "this is true"); + +assert.throws(TypeError, function() { + sort.call(false, comparefn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + sort.call(s, comparefn); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..1d32b8a647882d853f577c22bce63a10f19ce687 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-%typedarray%.prototype.sort +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.26 %TypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value as the argument. + 2. Let buffer be ? ValidateTypedArray(obj). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var sort = TypedArray.prototype.sort; +var comparefn = function() {}; + +assert.throws(TypeError, function() { + sort.call({}, comparefn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + sort.call([], comparefn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + sort.call(ab, comparefn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + sort.call(dv, comparefn); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/subarray/this-is-not-object.js b/test/built-ins/TypedArray/prototype/subarray/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..36cf455c2677b6111a8ff25a7c1393a72dcb53ad --- /dev/null +++ b/test/built-ins/TypedArray/prototype/subarray/this-is-not-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. +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.27 %TypedArray%.prototype.subarray( begin , end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var subarray = TypedArray.prototype.subarray; + +assert.throws(TypeError, function() { + subarray.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + subarray.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + subarray.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + subarray.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + subarray.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + subarray.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + subarray.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..1a27efb4aba8aa74c23bf93e9570687a7eabe7b8 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -0,0 +1,38 @@ +// 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: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.9 %TypedArray%.prototype.subarray( begin , end ) + + The following steps are taken: + + 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] +---*/ + +var subarray = TypedArray.prototype.subarray; + +assert.throws(TypeError, function() { + subarray.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + subarray.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + subarray.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + subarray.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..9d021417a68fd0decdf5138819e64f0b379c79ab --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var toLocaleString = TypedArray.prototype.toLocaleString; + +assert.throws(TypeError, function() { + toLocaleString.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + toLocaleString.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + toLocaleString.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + toLocaleString.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + toLocaleString.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + toLocaleString.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + toLocaleString.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..49d0d75513fbeff809eaf32edb720f18f138a4f8 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.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-%typedarray%.prototype.tolocalestring +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.28 %TypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var toLocaleString = TypedArray.prototype.toLocaleString; + +assert.throws(TypeError, function() { + toLocaleString.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + toLocaleString.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + toLocaleString.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + toLocaleString.call(dv); +}, "this is a DataView instance"); diff --git a/test/built-ins/TypedArray/prototype/toString/prop-desc.js b/test/built-ins/TypedArray/prototype/toString/prop-desc.js deleted file mode 100644 index c5277b14777f7966d2966e5f197c994d2ff355c1..0000000000000000000000000000000000000000 --- a/test/built-ins/TypedArray/prototype/toString/prop-desc.js +++ /dev/null @@ -1,19 +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.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"); diff --git a/test/built-ins/TypedArray/prototype/values/this-is-not-object.js b/test/built-ins/TypedArray/prototype/values/this-is-not-object.js new file mode 100644 index 0000000000000000000000000000000000000000..ee50dcbe5f286ca8f485d4b892ca8035815e2ced --- /dev/null +++ b/test/built-ins/TypedArray/prototype/values/this-is-not-object.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. +/*--- +esid: sec-%typedarray%.prototype.values +description: Throws a TypeError exception when `this` is not Object +info: > + 22.2.3.30 %TypedArray%.prototype.values ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol] +---*/ + +var values = TypedArray.prototype.values; + +assert.throws(TypeError, function() { + values.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + values.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + values.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + values.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + values.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + values.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + values.call(s); +}, "this is a Symbol"); diff --git a/test/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/test/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js new file mode 100644 index 0000000000000000000000000000000000000000..f8c89f9af2e0f8209d10cdfa799365ab77b37ae3 --- /dev/null +++ b/test/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.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. +/*--- +esid: sec-%typedarray%.prototype.values +description: | + Throws a TypeError exception when `this` is not a TypedArray instance +info: > + 22.2.3.30 %TypedArray%.prototype.values ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +---*/ + +var values = TypedArray.prototype.values; + +assert.throws(TypeError, function() { + values.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + values.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + values.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + values.call(dv); +}, "this is a DataView instance");