summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js
blob: 1ffa00c9a371ad00f3f43fd4f96ef4de47f3b2e5 (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
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.lastindexof
description: >
  Returns -1 if length is 0.
info: |
  Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )

  1. Let O be ? ToObject(this value).
  2. Let len be ? LengthOfArrayLike(O).
  3. If len is 0, return -1.
---*/

var fromIndex = {
  valueOf: function() {
    throw new Test262Error("Length should be checked before ToInteger(fromIndex).");
  },
};

assert.sameValue([].lastIndexOf(1), -1);
assert.sameValue([].lastIndexOf(2, fromIndex), -1);

reportCompare(0, 0);