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
This commit is contained in:
smikes 2014-10-27 10:09:54 -06:00 committed by Brian Terlson
parent 0dbafac5a6
commit 5318ee7b1f
8 changed files with 75 additions and 26 deletions

View File

@ -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);

View File

@ -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 () {}));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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');
}
});

View File

@ -3,6 +3,7 @@
/*---
description: Array.prototype.find should convert thisArg into an object
flags: [noStrict]
---*/
var dataTypes = [

View File

@ -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');
}
});