ability to run code and check output in tests

This commit is contained in:
2024-12-28 13:19:15 -08:00
parent 95f90c8698
commit a6e68ac2a2
62 changed files with 459 additions and 31 deletions

24
tests/Auto.newt Normal file
View File

@@ -0,0 +1,24 @@
module Auto
pfunc i2s : Int -> String := `(i) => ''+i`
pfunc _++_ : String -> String -> String := `(a,b) => a + b`
infixl 4 _++_
-- We need sugar and marking as class/instance on all of this
data Show : U -> U where
MkShow : { A : U } -> ((show : A) -> String) -> Show A
-- FIXME - we'd like to inline this, so `show _ {{showInt}} a` ends up as `i2s a`
show : {A : U} {{myshow : Show A}} -> A -> String
show {_} {{MkShow foo}} a = foo a
showInt : Show Int
showInt = MkShow i2s
ptype World
pfunc log : {A : U} -> A -> World := `(_, a) => console.log(a)`
main : Int -> World
main _ = log ("answer: " ++ show 42)