mirror of https://github.com/tc39/test262.git
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:
parent
0dbafac5a6
commit
5318ee7b1f
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js
vendored
Normal file
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-1.js
vendored
Normal 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);
|
||||
|
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-2.js
vendored
Normal file
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-Proxy-2.js
vendored
Normal 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 () {}));
|
||||
|
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-arrowfunction.js
vendored
Normal file
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-arrowfunction.js
vendored
Normal 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);
|
||||
|
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-forEach.js
vendored
Normal file
13
test/built-ins/Array/prototype/find/Array.prototype.find_callable-forEach.js
vendored
Normal 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);
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
});
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
/*---
|
||||
description: Array.prototype.find should convert thisArg into an object
|
||||
flags: [noStrict]
|
||||
---*/
|
||||
|
||||
var dataTypes = [
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue