PZ7: Tester has error in assertion

Given from the logs:

[tester::#PZ7] [test-4.lox] var a = "1";
[tester::#PZ7] [test-4.lox] print a; // Should print 1
[tester::#PZ7] [test-4.lox] 
[tester::#PZ7] [test-4.lox] var a;
[tester::#PZ7] [test-4.lox] print a; // Should print nil
[tester::#PZ7] [test-4.lox] 
[tester::#PZ7] [test-4.lox] var a = "2";
[tester::#PZ7] [test-4.lox] print a; // Should print 2
[tester::#PZ7] [test-4.lox] 
[tester::#PZ7] [test-4.lox] {
[tester::#PZ7] [test-4.lox]   // First declaration in local scope
[tester::#PZ7] [test-4.lox]   var a = "1";
[tester::#PZ7] [test-4.lox] 
[tester::#PZ7] [test-4.lox]   // Attempting to redeclare in local scope
[tester::#PZ7] [test-4.lox]   var a = "2"; // This should be a compile error
[tester::#PZ7] [test-4.lox]   print a;
[tester::#PZ7] [test-4.lox] }
[tester::#PZ7] [test-4] $ ./your_program.sh run test.lox
[your_program] 1
[your_program] nil
[your_program] 2
[tester::#PZ7] [test-4] 𐄂 1
[tester::#PZ7] [test-4] Expected line #1 on stdout to be "", got "1"
[tester::#PZ7] [test-4] Test failed

Tester is appearing to have a mistake asserting the output

Hey @maximtereshchenko, stdout should be empty because the test program shouldn’t run at all due to this error:

[tester::#PZ7] [test-4.lox]   // Attempting to redeclare in local scope
[tester::#PZ7] [test-4.lox]   var a = "2"; // This should be a compile error

OK, I’ve double checked the behaviour with GitHub - munificent/craftinginterpreters: Repository for the book "Crafting Interpreters". Indeed, the reference implementation does not print anything. Could I suggest @andy1li not to use comments like print a; // Should print 1? It is misleading, and give an impression that it should actually output something

2 Likes

We have fixed the misleading comments in this PR.
Thanks for bringing this to our attention!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.