diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js new file mode 100644 index 0000000000..a205bc2caa --- /dev/null +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js @@ -0,0 +1,13 @@ +// Copyright (c) 2014 Matthew Meyers. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Array.prototype.find shouldn't throw a TypeError if + IsCallable(predicate) is true; Proxy is callable +features: [Array#find, Proxy] +---*/ + + +[].find(Proxy); + diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-2.js b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-2.js new file mode 100644 index 0000000000..d6d49649d7 --- /dev/null +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-2.js @@ -0,0 +1,13 @@ +// Copyright (c) 2014 Matthew Meyers. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Array.prototype.find shouldn't throw a TypeError if + IsCallable(predicate) is true; a new Proxy object is callable +features: [Array#find, Proxy] +---*/ + + +[].find(new Proxy(function () {}, function () {})); + diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-arrowfunction.js b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-arrowfunction.js new file mode 100644 index 0000000000..4f63feb5a9 --- /dev/null +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-arrowfunction.js @@ -0,0 +1,13 @@ +// Copyright (c) 2014 Matthew Meyers. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Array.prototype.find shouldn't throw a TypeError if + IsCallable(predicate) is true; arrow functions are callable +features: [Array#find, arrow-function] +---*/ + + +[].find(x => x); + diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-forEach.js b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-forEach.js new file mode 100644 index 0000000000..16ad7713ce --- /dev/null +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-forEach.js @@ -0,0 +1,13 @@ +// Copyright (c) 2014 Matthew Meyers. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Array.prototype.find shouldn't throw a TypeError if + IsCallable(predicate) is true; Array#forEach is callable +features: [Array#find] +---*/ + + +[].find(Array.prototype.forEach); + diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-predicate.js b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-predicate.js index debf13f88b..4b3b47eb8e 100644 --- a/test/built-ins/Array/prototype/find/Array.prototype.find_callable-predicate.js +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_callable-predicate.js @@ -4,29 +4,10 @@ /*--- description: > Array.prototype.find shouldn't throw a TypeError if - IsCallable(predicate) is true -includes: [runTestCase.js] + IsCallable(predicate) is true; a function is callable +features: [Array#find] ---*/ -var callableValues = [ - function () {}, - Array.prototype.forEach, - Proxy, - new Proxy(function () {}, function () {}), - x => x -]; -function testcase() { - for (var i = 0, len = callableValues.length; i < len; i++) { - try { - [].find(callableValues[i]); - } catch (e) { - if (e instanceof TypeError) { - return false; - } - } - } - return true; -} +[].find(function () {}); -runTestCase(testcase); diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_this-global.js b/test/built-ins/Array/prototype/find/Array.prototype.find_this-global.js new file mode 100644 index 0000000000..7e94715481 --- /dev/null +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_this-global.js @@ -0,0 +1,15 @@ +// Copyright (c) 2014 Matthew Meyers. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: thisArg should be global object if not provided (not Strict mode) +flags: [noStrict] +includes: [fnGlobalObject.js] +---*/ + + +[1].find(function () { + if (this !== fnGlobalObject()) { + $ERROR('#1: this !== global object'); + } +}); diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_this-is-object.js b/test/built-ins/Array/prototype/find/Array.prototype.find_this-is-object.js index df99acc48d..d328a04735 100644 --- a/test/built-ins/Array/prototype/find/Array.prototype.find_this-is-object.js +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_this-is-object.js @@ -3,6 +3,7 @@ /*--- description: Array.prototype.find should convert thisArg into an object +flags: [noStrict] ---*/ var dataTypes = [ diff --git a/test/built-ins/Array/prototype/find/Array.prototype.find_this-undefined.js b/test/built-ins/Array/prototype/find/Array.prototype.find_this-undefined.js index eede30e89a..2c3042a1b2 100644 --- a/test/built-ins/Array/prototype/find/Array.prototype.find_this-undefined.js +++ b/test/built-ins/Array/prototype/find/Array.prototype.find_this-undefined.js @@ -2,13 +2,13 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: thisArg should be undefined if not provided +description: thisArg should be undefined if not provided (Strict mode) +flags: [onlyStrict] ---*/ -var globalThis = this; [1].find(function () { - if (this !== globalThis) { - $ERROR('#1: this !== globalThis'); + if (this !== undefined) { + $ERROR('#1: this !== undefined'); } });