Backed out 3 changesets (bug 1892041) for causing failures on async-module-does-not...
[gecko.git] / js / src / tests / test262 / built-ins / Array / prototype / findIndex / predicate-not-called-on-empty-array.js
blobc3bd339896d8965ac6ce7e37d7fab0b893fe29c5
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-array.prototype.findindex
5 description: >
6   Predicate is only called if this.length is > 0.
7 info: |
8   22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] )
10   ...
11   7. Let k be 0.
12   8. Repeat, while k < len
13     ...
14     d. Let testResult be ToBoolean(Call(predicate, T, «kValue, k, O»)).
15   ...
16   9. Return -1.
17 ---*/
19 var called = false;
21 var predicate = function() {
22   called = true;
23   return true;
26 var result = [].findIndex(predicate);
28 assert.sameValue(
29   called, false,
30   '[].findIndex(predicate) does not call predicate'
32 assert.sameValue(
33   result, -1,
34   '[].findIndex(predicate) returned undefined'
37 reportCompare(0, 0);