set test_name "Printing" set command_line "./jlox" spawn $command_line send "print \"Hello, world!\";\n" expect { "Error at" { fail "$test_name: error: $expect_out(buffer)\n" } "> Hello, world!" { pass "$test_name" } eof { fail "$test_name: Premature end of file: $expect_out(buffer)\n" } timeout { fail "$test_name: timed out\n" } } set test_name "Local Functions and Closures" spawn $command_line send "fun makeCounter() { var i = 0; fun count() { i = i + 1; print i; } return count; } var counter = makeCounter(); counter(); counter(); " expect { "Error at" { fail "$test_name: error: $expect_out(buffer)\n" } -re "> 1.*?> 2" { pass "$test_name" } eof { fail "$test_name: Premature end of file: $expect_out(buffer)\n" } timeout { fail "$test_name: timed out\n" } }