More language tests needed + examples,test cleanup.
alsonkemp opened this issue · 3 comments
I'm working on the parser and many of the language's features seem to be lacking sample code. Examples:
In CallArgument:
["[| expression |]", n("$$ = new yy.Quoted($2);")],
In Type Function:
["FUNCTION ( optTypeFunctionArgList )", "$$ = new yy.TypeFunction($3);"],
(Aha, I see an example of [| |] in examples/macro.roy...)
It would be very helpful to have a thorough and unified set of test cases. Also, you/we might merge most of examples/ into tests/ since many examples would be useful as tests, too. examples/ should probably hold larger pieces of code that demonstrate the overall language.
I'm happy to do this task if you think it would be beneficial.
I stuffed up a while ago and tried writing my own test runner for Roy instead of using an existing one.
I need to start testing the non-happy paths and more of the compiler internals. I'll start doing that in the coming months - any improvements in the meantime are greatly welcomed.
I think that this is related: Some of the example code itself is broken:
data Either a b =
Left a | Right b
let printString (s: String) =
console.log s
let printResult e = match e
case (Left x) = console.log x
case (Right x) = printString x
printResult (Left 10)
printResult (Right "Error")
// Won't compile:
printResult (Right 10)
actually compiles fine.
Do we need some kind of test runner that goes through the examples and uncomments each "// Won't compile" block in turn and makes sure it doesn't compile?
To clarify: found this code in the "tagged union" section of http://roy.brianmckenna.org/, and uncommented the last line.
I just pasted this into repl.it and it broke as expected.
I'm new to this language, so I don't really know what's broken here/which versions are broken.