mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 12:15:09 +00:00
LibJS: Handle "for" statements with empty initializer and updater
This commit is contained in:
parent
30d24af54a
commit
6c9d2cfa5e
3 changed files with 26 additions and 2 deletions
24
Libraries/LibJS/Tests/for-basic.js
Normal file
24
Libraries/LibJS/Tests/for-basic.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
function assert(x) { if (!x) throw 1; }
|
||||
|
||||
try {
|
||||
var a = [];
|
||||
for (var i = 0; i < 3; ++i) {
|
||||
a.push(i);
|
||||
}
|
||||
assert(a.length === 3);
|
||||
assert(a[0] === 0);
|
||||
assert(a[1] === 1);
|
||||
assert(a[2] === 2);
|
||||
|
||||
for (; a.length < 6;) {
|
||||
a.push('x');
|
||||
}
|
||||
assert(a.length === 6);
|
||||
assert(a[3] === 'x');
|
||||
assert(a[4] === 'x');
|
||||
assert(a[5] === 'x');
|
||||
|
||||
console.log("PASS");
|
||||
} catch (e) {
|
||||
console.log("FAIL: " + e);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue