Skip to content

Commit

Permalink
Add test case for variable scope
Browse files Browse the repository at this point in the history
  • Loading branch information
andy1li committed Sep 20, 2024
1 parent 97d090d commit 0981a2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/test_helpers/fixtures/pass_statements
Original file line number Diff line number Diff line change
Expand Up @@ -496,20 +496,25 @@ Debug = true
[stage-1] [test-4] Running test case: 4
[stage-1] [test-4] Writing contents to ./test.lox:
[stage-1] [test-4] [test.lox] {
[stage-1] [test-4] [test.lox] var world = "outer world";
[stage-1] [test-4] [test.lox] var bar = "outer bar";
[stage-1] [test-4] [test.lox] {
[stage-1] [test-4] [test.lox] world = "modified world";
[stage-1] [test-4] [test.lox] var bar = "inner bar";
[stage-1] [test-4] [test.lox] print world;
[stage-1] [test-4] [test.lox] print bar;
[stage-1] [test-4] [test.lox] }
[stage-1] [test-4] [test.lox] print bar;
[stage-1] [test-4] [test.lox] print world;<|SPACE|> print bar;
[stage-1] [test-4] [test.lox] }
[stage-1] [test-4] [test.lox] print bar;
[stage-1] [test-4] [test.lox]
[stage-1] [test-4] $ ./your_program.sh run test.lox
[your_program] modified world
[your_program] inner bar
[your_program] modified world
[your_program] outer bar
[your_program] Undefined variable 'bar'.
[your_program] [line 9]
[stage-1] [test-4] ✓ 2 line(s) match on stdout
[your_program] [line 13]
[stage-1] [test-4] ✓ 4 line(s) match on stdout
[stage-1] [test-4] ✓ Received exit code 70.
[stage-1] Test passed.
4 changes: 4 additions & 0 deletions test_programs/s10/4.lox
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
expected_error_type: runtime
---
{
var <<RANDOM_STRING_1>> = "outer <<RANDOM_STRING_1>>";
var <<RANDOM_STRING_2>> = "outer <<RANDOM_STRING_2>>";
{
<<RANDOM_STRING_1>> = "modified <<RANDOM_STRING_1>>";
var <<RANDOM_STRING_2>> = "inner <<RANDOM_STRING_2>>";
print <<RANDOM_STRING_1>>;
print <<RANDOM_STRING_2>>;
}
print <<RANDOM_STRING_1>>;
print <<RANDOM_STRING_2>>;
}
print <<RANDOM_STRING_2>>;

0 comments on commit 0981a2d

Please sign in to comment.