From 470730bcb8abf697dc218866c09fffa1a1045fb0 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Mon, 7 Mar 2011 21:59:32 -0500 Subject: [PATCH] trying to trace application --- compile.rkt | 3 ++- test-compiler.rkt | 36 +++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/compile.rkt b/compile.rkt index 7e3ead9..ff6b722 100644 --- a/compile.rkt +++ b/compile.rkt @@ -355,7 +355,8 @@ (make-instruction-sequence `(,(make-AssignPrimOpStatement target - (make-ApplyPrimitiveProcedure n))))) + (make-ApplyPrimitiveProcedure n)) + ,(make-PopEnvironment n 0)))) after-call)))) diff --git a/test-compiler.rkt b/test-compiler.rkt index 5e38f78..de1e217 100644 --- a/test-compiler.rkt +++ b/test-compiler.rkt @@ -92,6 +92,27 @@ (test (begin 1) 1) + +(test (+ (* 3 4) 5) + 17) + + + +;; Square +(test (begin (define (f x) + (* x x)) + (f 3)) + 9) + + + +;; composition of square +(test (begin (define (f x) + (* x x)) + (f (f 3))) + 81) + + ;; Simple application (test ((lambda (x) x) 42) 42) @@ -105,26 +126,15 @@ (test ((lambda (x y z) z) 3 4 5) 5) +;; And this should fail because it's not a lambda +(test/exn (not-a-procedure 5)) ;; We should see an error here, since the arity is wrong (test/exn ((lambda (x y z) x) 3)) (test/exn ((lambda (x y z) z) 3)) (test/exn ((lambda (x y z) x) 3 4 5 6)) -;; And this should fail because it's not a lambda -(test/exn (not-a-procedure 5)) -;; Square -(test (begin (define (f x) - (* x x)) - (f 3)) - 9) - -;; composition of square -(test (begin (define (f x) - (* x x)) - (f (f 3))) - 81) ; factorial