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
+38
View File
@@ -151,3 +151,41 @@ try {
assert (e.message === "foo");
assert (e instanceof ReferenceError);
}
function array_check(result_array, expected_array) {
assert(result_array instanceof Array);
assert(result_array.length === expected_array.length);
for (var idx = 0; idx < expected_array.length; idx++) {
assert(result_array[idx] === expected_array[idx]);
}
}
// Remove the buffer
var array = [1, 2, 3, 4, 5];
var value = array.slice(4, {
valueOf: function() {
array.length = 0;
}
})
array_check(value, []);
// Extend the buffer
var array = [1, 2, 3, 4, 5];
var value = array.slice(6, {
valueOf: function() {
array.length = 10;
}
})
array_check(value, []);
// Reduce the buffer
var array = [1, 2, 3, 4, 5];
var value = array.slice(1, {
valueOf: function() {
array.length = 3;
}
})
array_check(value, []);