Skip to content
Snippets Groups Projects
Commit 83b27c9b authored by Leonardo Balter's avatar Leonardo Balter Committed by Mike Pennisi
Browse files

Add validation tests for TypedArray instance methods

parent b26190f1
No related branches found
No related tags found
No related merge requests found
Showing
with 929 additions and 0 deletions
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
// 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");
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment