summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/findLastIndex/maximum-index.js
blob: 27489250fdc0066ed2b8ab851559a9c81f71ff58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2023 Richard Gibson. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.findlastindex
description: >
  Support the maximum valid integer index.
info: |
  Array.prototype.findLastIndex ( predicate [ , thisArg ] )

  1. Let O be ? ToObject(this value).
  2. Let len be ? LengthOfArrayLike(O).

  LengthOfArrayLike ( obj )

  1. Return ℝ(? ToLength(? Get(obj, "length"))).

  ToLength ( argument )

  1. Let len be ? ToIntegerOrInfinity(argument).
  2. If len ≤ 0, return +0𝔽.
  3. Return 𝔽(min(len, 2**53 - 1)).
features: [array-find-from-last]
---*/

var tooBigLength = Number.MAX_VALUE;
var maxExpectedIndex = 9007199254740990;
var arrayLike = { length: tooBigLength };
var calledWithIndex = [];

Array.prototype.findLastIndex.call(arrayLike, function(_value, index) {
  calledWithIndex.push(index);
  return true;
});

assert.sameValue(calledWithIndex.length, 1, 'predicate invoked once');
assert.sameValue(calledWithIndex[0], maxExpectedIndex);

reportCompare(0, 0);