Skip to content
Snippets Groups Projects
Commit 5318ee7b authored by smikes's avatar smikes Committed by Brian Terlson
Browse files

minor fixes to Array.protoype.find tests

split "this" tests into strict/nonstrict branches
split callable into separate test cases

metadata: rename es6 to features
parent 0dbafac5
No related branches found
No related tags found
No related merge requests found
// 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);
// 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 () {}));
// 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);
// 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);
...@@ -4,29 +4,10 @@ ...@@ -4,29 +4,10 @@
/*--- /*---
description: > description: >
Array.prototype.find shouldn't throw a TypeError if Array.prototype.find shouldn't throw a TypeError if
IsCallable(predicate) is true IsCallable(predicate) is true; a function is callable
includes: [runTestCase.js] features: [Array#find]
---*/ ---*/
var callableValues = [
function () {},
Array.prototype.forEach,
Proxy,
new Proxy(function () {}, function () {}),
x => x
];
function testcase() { [].find(function () {});
for (var i = 0, len = callableValues.length; i < len; i++) {
try {
[].find(callableValues[i]);
} catch (e) {
if (e instanceof TypeError) {
return false;
}
}
}
return true;
}
runTestCase(testcase);
// 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');
}
});
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
/*--- /*---
description: Array.prototype.find should convert thisArg into an object description: Array.prototype.find should convert thisArg into an object
flags: [noStrict]
---*/ ---*/
var dataTypes = [ var dataTypes = [
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// This code is governed by the BSD license found in the LICENSE file. // 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 () { [1].find(function () {
if (this !== globalThis) { if (this !== undefined) {
$ERROR('#1: this !== globalThis'); $ERROR('#1: this !== undefined');
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment