31 lines
619 B
Racket
31 lines
619 B
Racket
#lang racket
|
|
|
|
(provide lint-tests)
|
|
|
|
(require rackunit)
|
|
(require "test-util.rkt")
|
|
(require "../lint.rkt")
|
|
|
|
(define eight (Int 8))
|
|
(define rd (Prim 'read '()))
|
|
(define neg-eight (Prim '- (list eight)))
|
|
(define ast1.1 (Prim '+ (list rd neg-eight)))
|
|
(define program (Program '() ast1.1))
|
|
|
|
(define lint-tests
|
|
(test-suite
|
|
"Lint interpretation tests"
|
|
(test-case
|
|
"program with input"
|
|
(check-equal?
|
|
-5
|
|
(with-input-from-num-list '(3)
|
|
(lambda () (interp-Lint program)))))
|
|
(test-case
|
|
"simple difference"
|
|
(check-equal?
|
|
-3
|
|
(interp-Lint (Program '() (Prim '- (list (Int 5) (Int 8)))))))))
|
|
|
|
|