RInt -> Lint

This commit is contained in:
Enrico Lumetti 2024-01-18 09:53:11 +01:00
parent 195cfbd248
commit a858cbee76
3 changed files with 10 additions and 10 deletions

View File

@ -2,7 +2,7 @@
(require racket/fixnum)
(provide Int Prim Program interp-RInt)
(provide Int Prim Program interp-Lint)
(struct Int (value))
(struct Prim (op args))
@ -24,6 +24,6 @@
[(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)
(define (interp-Lint p)
(match p
[(Program '() body) (interp-exp body)]))

View File

@ -3,7 +3,7 @@
(provide all-tests)
(require rackunit)
(require "test-rint.rkt")
(require "test-lint.rkt")
(require "test-rvar.rkt")
(require "test-cvar.rkt")
(require "test-uniquify.rkt")
@ -16,7 +16,7 @@
(define all-tests
(test-suite
"All tests"
rint-tests
lint-tests
rvar-tests
cvar-tests
uniquify-tests

View File

@ -1,10 +1,10 @@
#lang racket
(provide rint-tests)
(provide lint-tests)
(require rackunit)
(require "test-util.rkt")
(require "../rint.rkt")
(require "../lint.rkt")
(define eight (Int 8))
(define rd (Prim 'read '()))
@ -12,19 +12,19 @@
(define ast1.1 (Prim '+ (list rd neg-eight)))
(define program (Program '() ast1.1))
(define rint-tests
(define lint-tests
(test-suite
"RInt interpretation tests"
"Lint interpretation tests"
(test-case
"program with input"
(check-equal?
-5
(with-input-from-num-list '(3)
(lambda () (interp-RInt program)))))
(lambda () (interp-Lint program)))))
(test-case
"simple difference"
(check-equal?
-3
(interp-RInt (Program '() (Prim '- (list (Int 5) (Int 8)))))))))
(interp-Lint (Program '() (Prim '- (list (Int 5) (Int 8)))))))))