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

View File

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

View File

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