Compare commits
No commits in common. "18ebacb00bd163d94d928900080a2075f92c56fb" and "a376f31d4abd191caf0a36ed0b1db42eb740c173" have entirely different histories.
18ebacb00b
...
a376f31d4a
|
|
@ -1,52 +0,0 @@
|
||||||
#lang racket
|
|
||||||
|
|
||||||
(provide read-bril-file read-rvar-file complete-tests)
|
|
||||||
|
|
||||||
(require json rackunit (only-in bril program-to-jsexpr))
|
|
||||||
|
|
||||||
(require "uniquify.rkt")
|
|
||||||
(require "remove-complex-oper.rkt")
|
|
||||||
(require "explicate-control.rkt")
|
|
||||||
(require "cvar-to-bril.rkt")
|
|
||||||
|
|
||||||
(define-namespace-anchor anc)
|
|
||||||
(define ns (namespace-anchor->namespace anc))
|
|
||||||
|
|
||||||
(define (read-bril-file path)
|
|
||||||
(with-input-from-file path
|
|
||||||
(lambda () (read-json))))
|
|
||||||
|
|
||||||
(define (read-rvar-file path)
|
|
||||||
(with-input-from-file path
|
|
||||||
(lambda ()
|
|
||||||
(parameterize ([current-namespace ns])
|
|
||||||
(namespace-attach-module-declaration ns '"rvar.rkt")
|
|
||||||
(namespace-require '"rvar.rkt")
|
|
||||||
(eval (read))))))
|
|
||||||
|
|
||||||
(define (rvar-to-cvar program)
|
|
||||||
(explicate-control (remove-complex-opera*-2 (uniquify program))))
|
|
||||||
|
|
||||||
(define (rvar-to-bril-json program)
|
|
||||||
(program-to-jsexpr (cvar-to-bril (rvar-to-cvar program))))
|
|
||||||
|
|
||||||
(define (complete-rvar-test test-desc rvar-path bril-path)
|
|
||||||
(test-case
|
|
||||||
test-desc
|
|
||||||
(let ([rvar (read-rvar-file rvar-path)]
|
|
||||||
[bril (read-bril-file bril-path)])
|
|
||||||
(test-case
|
|
||||||
"RVar->bril"
|
|
||||||
(parameterize ([current-namespace ns])
|
|
||||||
(namespace-attach-module-declaration ns '"rvar.rkt")
|
|
||||||
(namespace-require '"rvar.rkt")
|
|
||||||
(check-equal? bril (rvar-to-bril-json rvar)))))))
|
|
||||||
|
|
||||||
(define complete-tests
|
|
||||||
(test-suite
|
|
||||||
"Complete Tests"
|
|
||||||
(complete-rvar-test
|
|
||||||
"Simple RVar Tests"
|
|
||||||
"complete-tests/test1.rvar"
|
|
||||||
"complete-tests/test1.bril")))
|
|
||||||
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
{
|
|
||||||
"functions": [
|
|
||||||
{
|
|
||||||
"args": [],
|
|
||||||
"instrs": [
|
|
||||||
{
|
|
||||||
"label": "start"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dest": "tmp.0",
|
|
||||||
"op": "const",
|
|
||||||
"type": "int",
|
|
||||||
"value": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dest": "tmp.1",
|
|
||||||
"op": "const",
|
|
||||||
"type": "int",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"args": [
|
|
||||||
"tmp.1",
|
|
||||||
"tmp.0"
|
|
||||||
],
|
|
||||||
"dest": "tmp.1",
|
|
||||||
"funcs": [],
|
|
||||||
"labels": [],
|
|
||||||
"op": "sub",
|
|
||||||
"type": "int"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"dest": "tmp.2",
|
|
||||||
"op": "const",
|
|
||||||
"type": "int",
|
|
||||||
"value": 2
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"args": [
|
|
||||||
"tmp.1",
|
|
||||||
"tmp.2"
|
|
||||||
],
|
|
||||||
"dest": "tmp.3",
|
|
||||||
"funcs": [],
|
|
||||||
"labels": [],
|
|
||||||
"op": "add",
|
|
||||||
"type": "int"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"args": [
|
|
||||||
"tmp.3"
|
|
||||||
],
|
|
||||||
"funcs": [],
|
|
||||||
"labels": [],
|
|
||||||
"op": "return"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "main"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
(Program '()
|
|
||||||
(Prim '+
|
|
||||||
(list (Prim '- (list (Int 1)))
|
|
||||||
(Int 2))))
|
|
||||||
|
|
||||||
|
|
@ -47,9 +47,4 @@
|
||||||
(bril:ValueInstr 'sub dest (bril:Type 'int)
|
(bril:ValueInstr 'sub dest (bril:Type 'int)
|
||||||
(list dest
|
(list dest
|
||||||
(symbol->string v1))
|
(symbol->string v1))
|
||||||
'() '()))]
|
|
||||||
[(Prim '- (list (Var v1) (Var v2)))
|
|
||||||
(list (bril:ValueInstr 'sub dest (bril:Type 'int)
|
|
||||||
(list (symbol->string v1)
|
|
||||||
(symbol->string v2))
|
|
||||||
'() '()))]))
|
'() '()))]))
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#lang racket
|
|
||||||
|
|
||||||
(require rackunit rackunit/text-ui)
|
|
||||||
(require "tests/all-tests.rkt")
|
|
||||||
(require "complete-tests.rkt")
|
|
||||||
|
|
||||||
(run-tests all-tests)
|
|
||||||
(run-tests complete-tests)
|
|
||||||
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
(provide cvar-to-bril-tests)
|
(provide cvar-to-bril-tests)
|
||||||
|
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
(require "../cvar-to-bril.rkt")
|
(require "cvar-to-bril.rkt")
|
||||||
(require "../uniquify.rkt")
|
(require "uniquify.rkt")
|
||||||
(require "../remove-complex-oper.rkt")
|
(require "remove-complex-oper.rkt")
|
||||||
(require "../explicate-control.rkt")
|
(require "explicate-control.rkt")
|
||||||
(require "../rvar.rkt")
|
(require "rvar.rkt")
|
||||||
(require bril/interpreter)
|
(require bril/interpreter)
|
||||||
|
|
||||||
(define listings
|
(define listings
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
(require "test-util.rkt")
|
(require "test-util.rkt")
|
||||||
(require "../cvar.rkt")
|
(require "cvar.rkt")
|
||||||
|
|
||||||
(define seq-1
|
(define seq-1
|
||||||
(Return (Int 0)))
|
(Return (Int 0)))
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(provide rint-tests)
|
(provide test-rint-tests)
|
||||||
|
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
(require "test-util.rkt")
|
(require "test-util.rkt")
|
||||||
(require "../rint.rkt")
|
(require "rint.rkt")
|
||||||
|
|
||||||
(define eight (Int 8))
|
(define eight (Int 8))
|
||||||
(define rd (Prim 'read '()))
|
(define rd (Prim 'read '()))
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
(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 test-rint-tests
|
||||||
(test-suite
|
(test-suite
|
||||||
"RInt interpretation tests"
|
"RInt interpretation tests"
|
||||||
(test-case
|
(test-case
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(provide rvar-tests)
|
(provide test-rvar-tests)
|
||||||
|
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
(require "../rvar.rkt")
|
(require "rvar.rkt")
|
||||||
|
|
||||||
(define (interp-exp env e)
|
(define (interp-exp env e)
|
||||||
((send (new interp-RVar-class) interp-exp env) e))
|
((send (new interp-RVar-class) interp-exp env) e))
|
||||||
|
|
||||||
(define rvar-tests
|
(define test-rvar-tests
|
||||||
(test-suite
|
(test-suite
|
||||||
"RVar interpretation testsuite"
|
"RVar interpretation testsuite"
|
||||||
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(provide uniquify-tests)
|
(provide test-uniquify-tests)
|
||||||
|
|
||||||
(require rackunit)
|
(require rackunit)
|
||||||
|
|
||||||
(require "../rvar.rkt")
|
(require "rvar.rkt")
|
||||||
(require "../uniquify.rkt")
|
(require "uniquify.rkt")
|
||||||
(require/expose "../uniquify.rkt" (uniquify-exp))
|
(require/expose "uniquify.rkt" (uniquify-exp))
|
||||||
|
|
||||||
; returns both the resulting symtable and the uniquified program
|
; returns both the resulting symtable and the uniquified program
|
||||||
(define (list-uniquify-exp symtable)
|
(define (list-uniquify-exp symtable)
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
(Var 'y))
|
(Var 'y))
|
||||||
(Prim '+ (list (Var 'x) (Int 5))))))
|
(Prim '+ (list (Var 'x) (Int 5))))))
|
||||||
|
|
||||||
(define uniquify-tests
|
(define test-uniquify-tests
|
||||||
(test-suite
|
(test-suite
|
||||||
"Uniquify pass testsuite"
|
"Uniquify pass testsuite"
|
||||||
(test-case
|
(test-case
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
#lang racket
|
|
||||||
|
|
||||||
(provide all-tests)
|
|
||||||
|
|
||||||
(require rackunit)
|
|
||||||
(require "test-rint.rkt")
|
|
||||||
(require "test-rvar.rkt")
|
|
||||||
(require "test-cvar.rkt")
|
|
||||||
(require "test-uniquify.rkt")
|
|
||||||
;(require "test-remove-complex-opera.rkt")
|
|
||||||
;(require "test-explicate-control.rkt")
|
|
||||||
(require "test-cvar-to-bril.rkt")
|
|
||||||
|
|
||||||
(define all-tests
|
|
||||||
(test-suite
|
|
||||||
"All tests"
|
|
||||||
rint-tests
|
|
||||||
rvar-tests
|
|
||||||
cvar-tests
|
|
||||||
uniquify-tests
|
|
||||||
;remove-complex-opera-tests
|
|
||||||
;explicate-control-tests
|
|
||||||
cvar-to-bril-tests))
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue