yurtsiv / mooncake

🌜 A functional, dynamic programming language
MIT License
12 stars 4 forks source link

Test interpreter for false positives #3

Closed yurtsiv closed 3 years ago

yurtsiv commented 3 years ago

Currently, there are only tests for the positive outcomes of the interpreter. Negative/error cases should be tested too, similar to what we have in parser tests. No need to check exact error messages as those are not very useful yet anyway, just need to make sure it fails where it should.

Examples of failing programs:

1 / 0 # can't divide by zero
a + 1 # no variable 'a'
# Condition should be boolean
if "something" then
  1
else
  0
end

There's plenty of those, ideally, we need to cover all cases where Left is returned from evaluate function in Eval.sh

If you find a case where it should fail but it doesn't, please create an issue.

mateidanut commented 3 years ago

Hello, I'd like to work on this! As I understand it, I'll have to modify the EvalSpec.hs file to contain something similar to the invalidProgramms found in ParserSpec.hs, right?

yurtsiv commented 3 years ago

Hi @mateidanut, Yep, you've got it totally correctly. Thanks for the PR, I'll take a look shortly.