forked from GitHub/gf-core
added test cases for computation with abstract syntax terms
This commit is contained in:
28
testsuite/runtime/eval/Test.gf
Normal file
28
testsuite/runtime/eval/Test.gf
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
abstract Test = {
|
||||||
|
|
||||||
|
fun f : Int -> Int -> Int ;
|
||||||
|
|
||||||
|
fun g : Int -> Int ;
|
||||||
|
def g 1 = 2 ;
|
||||||
|
|
||||||
|
fun g2 : Int -> Int -> Int ;
|
||||||
|
def g2 1 x = x ;
|
||||||
|
|
||||||
|
fun g0 : Int -> Int -> Int ;
|
||||||
|
def g0 = g2 ;
|
||||||
|
|
||||||
|
fun const : Int -> Int -> Int ;
|
||||||
|
def const x _ = x ;
|
||||||
|
|
||||||
|
cat Nat ;
|
||||||
|
|
||||||
|
data zero : Nat ;
|
||||||
|
succ : Nat -> Nat ;
|
||||||
|
err : Nat ;
|
||||||
|
|
||||||
|
fun dec : Nat -> Nat ;
|
||||||
|
def dec zero = zero ;
|
||||||
|
dec (succ n) = n ;
|
||||||
|
dec n = err ; -- for fall through checking
|
||||||
|
|
||||||
|
}
|
||||||
29
testsuite/runtime/eval/eval.gfs
Normal file
29
testsuite/runtime/eval/eval.gfs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
i testsuite/runtime/eval/Test.gf
|
||||||
|
|
||||||
|
pt -compute \x -> x 1
|
||||||
|
pt -compute ? 1
|
||||||
|
pt -compute (\x -> x 1) ?
|
||||||
|
pt -compute unknown_var
|
||||||
|
pt -compute unknown_var 1
|
||||||
|
pt -compute 1 2
|
||||||
|
pt -compute f 1 2
|
||||||
|
pt -compute \x -> x
|
||||||
|
pt -compute ?666
|
||||||
|
pt -compute f
|
||||||
|
pt -compute (\x -> x 2) (f 1)
|
||||||
|
pt -compute (\x -> x 2) 1
|
||||||
|
pt -compute g 1
|
||||||
|
pt -compute g 0
|
||||||
|
pt -compute \x -> g x
|
||||||
|
pt -compute g ?
|
||||||
|
pt -compute (\x -> x 5) (g2 1)
|
||||||
|
pt -compute (\x -> x 3) (\x -> x)
|
||||||
|
pt -compute g0
|
||||||
|
pt -compute (\x -> x 3.2) (\x -> f x)
|
||||||
|
pt -compute g0 2.3
|
||||||
|
pt -compute g0 ((\x -> f x) 0) 1
|
||||||
|
pt -compute const 3.14 "pi"
|
||||||
|
pt -compute dec (succ (succ zero))
|
||||||
|
pt -compute dec (succ ?)
|
||||||
|
pt -compute \x -> dec x
|
||||||
|
pt -compute dec ?
|
||||||
50
testsuite/runtime/eval/eval.gfs.gold
Normal file
50
testsuite/runtime/eval/eval.gfs.gold
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
\v0 -> v0 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
? 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
? 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unknown variable unknown_var
|
||||||
|
|
||||||
|
unknown variable unknown_var
|
||||||
|
|
||||||
|
literal of function type
|
||||||
|
|
||||||
|
f 1 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\v0 -> v0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?666
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
f 1 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
literal of function type
|
||||||
|
|
||||||
|
2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
g 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\v0 -> g v0
|
||||||
|
|
||||||
Reference in New Issue
Block a user