mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 12:32:41 +00:00
added lox test files
This commit is contained in:
parent
821f5c62bc
commit
0f3d0a15f0
268 changed files with 7497 additions and 3 deletions
26
lox.t/for/scope.lox
Normal file
26
lox.t/for/scope.lox
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
var i = "before";
|
||||
|
||||
// New variable is in inner scope.
|
||||
for (var i = 0; i < 1; i = i + 1) {
|
||||
print i; // expect: 0
|
||||
|
||||
// Loop body is in second inner scope.
|
||||
var i = -1;
|
||||
print i; // expect: -1
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// New variable shadows outer variable.
|
||||
for (var i = 0; i > 0; i = i + 1) {}
|
||||
|
||||
// Goes out of scope after loop.
|
||||
var i = "after";
|
||||
print i; // expect: after
|
||||
|
||||
// Can reuse an existing variable.
|
||||
for (i = 0; i < 1; i = i + 1) {
|
||||
print i; // expect: 0
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue