mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Add validation tests for TypedArray instance methods
This commit is contained in:
parent
b26190f1ce
commit
83b27c9beb
50
test/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/copyWithin/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
52
test/built-ins/TypedArray/prototype/entries/this-is-not-object.js
vendored
Normal file
52
test/built-ins/TypedArray/prototype/entries/this-is-not-object.js
vendored
Normal file
@ -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");
|
43
test/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js
vendored
Normal file
43
test/built-ins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/every/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/every/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/every/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/fill/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/fill/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
53
test/built-ins/TypedArray/prototype/filter/this-is-not-object.js
vendored
Normal file
53
test/built-ins/TypedArray/prototype/filter/this-is-not-object.js
vendored
Normal file
@ -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");
|
44
test/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js
vendored
Normal file
44
test/built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/find/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/find/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/find/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/findIndex/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/forEach/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/forEach/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/includes/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/includes/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/indexOf/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/join/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/join/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/join/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
52
test/built-ins/TypedArray/prototype/keys/this-is-not-object.js
vendored
Normal file
52
test/built-ins/TypedArray/prototype/keys/this-is-not-object.js
vendored
Normal file
@ -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");
|
43
test/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js
vendored
Normal file
43
test/built-ins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/map/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/map/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/map/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/reduce/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/reduce/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/reduceRight/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/reverse/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/reverse/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
75
test/built-ins/TypedArray/prototype/set/this-is-not-object.js
vendored
Normal file
75
test/built-ins/TypedArray/prototype/set/this-is-not-object.js
vendored
Normal file
@ -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");
|
55
test/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js
vendored
Normal file
55
test/built-ins/TypedArray/prototype/set/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
52
test/built-ins/TypedArray/prototype/slice/this-is-not-object.js
vendored
Normal file
52
test/built-ins/TypedArray/prototype/slice/this-is-not-object.js
vendored
Normal file
@ -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");
|
43
test/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js
vendored
Normal file
43
test/built-ins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/some/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/some/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/some/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
51
test/built-ins/TypedArray/prototype/sort/this-is-not-object.js
vendored
Normal file
51
test/built-ins/TypedArray/prototype/sort/this-is-not-object.js
vendored
Normal file
@ -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");
|
42
test/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js
vendored
Normal file
42
test/built-ins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
47
test/built-ins/TypedArray/prototype/subarray/this-is-not-object.js
vendored
Normal file
47
test/built-ins/TypedArray/prototype/subarray/this-is-not-object.js
vendored
Normal file
@ -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");
|
38
test/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js
vendored
Normal file
38
test/built-ins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
50
test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js
vendored
Normal file
50
test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-object.js
vendored
Normal file
@ -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");
|
41
test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js
vendored
Normal file
41
test/built-ins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
@ -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");
|
52
test/built-ins/TypedArray/prototype/values/this-is-not-object.js
vendored
Normal file
52
test/built-ins/TypedArray/prototype/values/this-is-not-object.js
vendored
Normal file
@ -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");
|
43
test/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js
vendored
Normal file
43
test/built-ins/TypedArray/prototype/values/this-is-not-typedarray-instance.js
vendored
Normal file
@ -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");
|
Loading…
x
Reference in New Issue
Block a user