Add tests
This commit is contained in:
parent
4d186e6b2b
commit
30133f80e7
8 changed files with 61 additions and 4 deletions
37
tests/parser.rkt
Normal file
37
tests/parser.rkt
Normal file
|
@ -0,0 +1,37 @@
|
|||
#lang typed/racket
|
||||
(require "../typed-parser.rkt")
|
||||
(require typed/rackunit)
|
||||
|
||||
(test-begin
|
||||
(check-equal? (parse-from-string
|
||||
#<<END
|
||||
I x = x ;
|
||||
K x y = x ;
|
||||
K1 x y = y ;
|
||||
S f g x = f x (g x) ;
|
||||
compose f g x = f (g x) ;
|
||||
twice f = compose f f ;
|
||||
Q x = Pack {3 , 1 } x ;
|
||||
P x = case x of
|
||||
<1> -> 0 ;
|
||||
<2> x -> 1 + P x
|
||||
END
|
||||
)
|
||||
'((define (I x) x)
|
||||
(define (K x y) x)
|
||||
(define (K1 x y) y)
|
||||
(define (S f g x) ((f x) (g x)))
|
||||
(define (compose f g x) (f (g x)))
|
||||
(define (twice f) ((compose f) f))
|
||||
(define (Q x) ((pack 3 1) x))
|
||||
(define (P x) (case x ((1 () 0) (2 (x) ((+ 1) (P x))))))))
|
||||
(check-equal? (parse-from-string
|
||||
#<<END
|
||||
foo o = let x = 4 ;
|
||||
y = let z = 3 ;
|
||||
k = 4 in k + z in
|
||||
x + y + o
|
||||
END
|
||||
) '((define (foo o)
|
||||
(let ((x 4)(y (let ((z 3)(k 4)) ((+ k) z))))
|
||||
((+ ((+ x) y)) o))))))
|
Loading…
Add table
Add a link
Reference in a new issue