Fix subtraction, convert tests to rackunit
This commit is contained in:
parent
a4dd0ded8f
commit
14d6b476bd
1
rint.rkt
1
rint.rkt
|
|
@ -21,6 +21,7 @@
|
|||
[(Int n) n]
|
||||
[(Prim 'read '()) (read-fixnum)]
|
||||
[(Prim '- (list e)) (fx- 0 (interp-exp e))]
|
||||
[(Prim '- (list e1 e2)) (fx- (interp-exp e1) (interp-exp e2))]
|
||||
[(Prim '+ (list e1 e2)) (fx+ (interp-exp e1) (interp-exp e2))]))
|
||||
|
||||
(define (interp-RInt p)
|
||||
|
|
|
|||
|
|
@ -15,11 +15,16 @@
|
|||
(define test-rint-tests
|
||||
(test-suite
|
||||
"RInt interpretation tests"
|
||||
(test-case
|
||||
(test-case
|
||||
"program with input"
|
||||
(check-equal?
|
||||
-5
|
||||
(with-input-from-num-list '(3)
|
||||
(lambda () (interp-RInt program)))))))
|
||||
(lambda () (interp-RInt program)))))
|
||||
(test-case
|
||||
"simple difference"
|
||||
(check-equal?
|
||||
-3
|
||||
(interp-RInt (Program '() (Prim '- (list (Int 5) (Int 8)))))))))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue