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:
parent
e35219b5ce
commit
df6696f576
3 changed files with 54 additions and 0 deletions
31
Libraries/LibJS/Tests/Array.prototype.reverse.js
Normal file
31
Libraries/LibJS/Tests/Array.prototype.reverse.js
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue