mirror of
https://github.com/tc39/test262.git
synced 2025-06-21 14:30:32 +02:00
Add Array.prototype.indexOf test
This commit is contained in:
parent
e0153b5957
commit
545e66b251
22
test/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js
vendored
Normal file
22
test/built-ins/Array/prototype/indexOf/length-zero-returns-minus-one.js
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// 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.indexof
|
||||||
|
description: >
|
||||||
|
Returns -1 if length is 0.
|
||||||
|
info: |
|
||||||
|
Array.prototype.indexOf ( 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([].indexOf(1), -1);
|
||||||
|
assert.sameValue([].indexOf(2, fromIndex), -1);
|
Loading…
x
Reference in New Issue
Block a user