1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

LibJS: Add Array.prototype.reverse

This commit is contained in:
Kesse Jones 2020-04-20 10:39:39 -03:00 committed by Andreas Kling
parent e35219b5ce
commit df6696f576
3 changed files with 54 additions and 0 deletions

View file

@ -0,0 +1,31 @@
load("test-common.js");
try {
assert(Array.prototype.reverse.length === 0);
var array = [1, 2, 3];
assert(array[0] === 1);
assert(array[1] === 2);
assert(array[2] === 3);
array.reverse();
assert(array[0] === 3);
assert(array[1] === 2);
assert(array[2] === 1);
var array_ref = array.reverse();
assert(array_ref[0] === 1);
assert(array_ref[1] === 2);
assert(array_ref[2] === 3);
assert(array[0] === 1);
assert(array[1] === 2);
assert(array[2] === 3);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}