Fix length check for Array.prototype indexOf, lastIndexOf and fill (#3798)

JerryScript-DCO-1.0-Signed-off-by: Adam Szilagyi aszilagy@inf.u-szeged.hu
This commit is contained in:
Szilagyi Adam
2020-06-05 12:20:26 +02:00
committed by GitHub
parent c09c2c5dd7
commit 252cfb0876
6 changed files with 197 additions and 7 deletions
@@ -69,3 +69,33 @@ try {
assert(e.message === "foo");
assert(e instanceof ReferenceError);
}
// Remove the buffer
var array = [1, 2, 3, 4, 5];
var value = array.lastIndexOf(4, {
valueOf: function() {
array.length = 0;
}
})
assert(value === -1);
// Extend the buffer
var array = [1, 2, 3];
var value = array.lastIndexOf(1, {
valueOf: function() {
array.length = 5;
}
})
assert(value === 0);
// Reduce the buffer
var array = [1, 2, 3, 4, 5, 6, 7];
var value = array.indexOf(5, {
valueOf: function() {
array.length = 2;
}
})
assert(value === -1);