ability to run code and check output in tests
This commit is contained in:
24
tests/Auto.newt
Normal file
24
tests/Auto.newt
Normal 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)
|
||||
Reference in New Issue
Block a user