Skip to content

Commit 961cfd5

Browse files
committed
refactor: remove unused stage directories and update ordering
1 parent fa02fb7 commit 961cfd5

File tree

21 files changed

+95
-129
lines changed

21 files changed

+95
-129
lines changed

test_programs/r1/1.lox

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
---
22
expected_error_type: none
33
---
4-
// The closure should capture the global variable and declaring a local
5-
// variable with the same name should not affect the closure's capture.
4+
// This variable is used in the function `f` below.
65
var variable = "global";
6+
77
{
88
fun f() {
99
print variable;
1010
}
1111

12-
f(); // expect: global
12+
f(); // this should print "global"
13+
14+
// This variable declaration shouldn't affect the usage in `f` above.
1315
var variable = "local";
14-
f(); // expect: global
16+
17+
f(); // this should still print "global"
1518
}

test_programs/r2/1.lox

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
expected_error_type: none
3+
---
4+
// Redeclaring a variable in the global scope should be allowed.
5+
var a = "value";
6+
var a = a; // global scope
7+
print a;

test_programs/r2/2.lox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
expected_error_type: compile
3+
---
4+
// A variable should not be able to be initialized with itself.
5+
var a = "outer";
6+
{
7+
var a = a; // Expect compile error.
8+
}

test_programs/r2/3.lox

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
expected_error_type: compile
3+
---
4+
// A variable should not be able to be initialized with itself.
5+
fun returnArg(arg) {
6+
return arg;
7+
}
8+
9+
var b = "global";
10+
11+
{
12+
var a = "first";
13+
// Using global 'b' through a function call
14+
var b = returnArg(b); // Expect compile error.
15+
print b;
16+
}
17+
18+
// Reassigning with self-reference is fine for globals
19+
var b = b + " updated";
20+
print b;

test_programs/r2/4.lox

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
expected_error_type: compile
3+
---
4+
// A variable should not be able to be initialized with itself.
5+
fun outer() {
6+
var a = "outer";
7+
8+
fun inner() {
9+
var a = a; // Error at 'a': Can't read local variable in its own initializer.
10+
print a;
11+
}
12+
13+
inner();
14+
}
15+
16+
outer();

test_programs/r4/1.lox

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
2-
expected_error_type: none
2+
expected_error_type: compile
33
---
4-
// Redeclaring a variable in the global scope should be allowed.
5-
var a = "value";
6-
var a = a; // global scope
7-
print a;
4+
fun foo() {
5+
return "at function scope is ok";
6+
}
7+
8+
return; // Error: Can't return from top-level code.

0 commit comments

Comments
 (0)