Closed stefanobaghino closed 10 months ago
Instead of describing the assertion in terms of a Lox expression, it's simpler to lookup the variable and run the assertion in the test framework as it's being done as part of #36. This makes assert
statements even less relevant. It might be worth just closing this.
Print statements work well to manually inspect the state, but asserts could help making it easier to test the language. The current approach is that of having the interpreter execute some statements and then passing an expression that evaluates a predicate, which is ultimately used to evaluate whether the code was interpreted correctly.
https://github.com/stefanobaghino/lox-interpreter/blob/3ce6e266a606000a93f2330056df5293c303c083/src/test/scala/lox/InterpreterTest.scala#L160-L172
This might be repackaged as a function after #7 is closed. Hypothetically, refactoring so that the state can be inspected without necessarily invoking the interpreter explicitly might make this point moot.