From 2b5e5c5b571c0bbee757edec8606a279667087b2 Mon Sep 17 00:00:00 2001 From: Jon Rafkind Date: Mon, 21 May 2012 14:32:48 -0600 Subject: [PATCH] [honu] combine string-append and the evaluator --- collects/tests/honu/check.rkt | 38 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/collects/tests/honu/check.rkt b/collects/tests/honu/check.rkt index 10366069de..2d2e4726fe 100644 --- a/collects/tests/honu/check.rkt +++ b/collects/tests/honu/check.rkt @@ -11,50 +11,48 @@ (lambda () (make-evaluator 'honu)))) -(define (honu input) - (with-input-from-string input +(define (honu . input) + (with-input-from-string (apply string-append input) (lambda () ((honu-eval) (honu-read-syntax))))) -(define input string-append) - (define-syntax-rule (honu-tests checks ...) (parameterize ([honu-eval (make-honu-evaluator)]) checks ...)) (honu-tests - (check-equal? (honu @input{1}) 1) - (check-equal? (honu @input{5}) 5) - (check-equal? (honu @input{1 + 1}) (+ 1 1)) - (check-equal? (honu @input{1 + 2 * 3}) (+ 1 (* 2 3))) - (check-equal? (honu @input{3 * 2 + 1}) (+ (* 3 2) 1)) - (check-equal? (honu @input{1 + 4 ^ 2 * 3}) (+ 1 (* (expt 4 2) 3))) - (check-equal? (honu @input{1 + 4 ^ 3 ^ 2}) (+ 1 (expt 4 (expt 3 2)))) - (check-equal? (honu @input{4 ^ 3 ^ 2 + 1}) (+ (expt 4 (expt 3 2)) 1)) + (check-equal? @honu{1} 1) + (check-equal? @honu{5} 5) + (check-equal? @honu{1 + 1} (+ 1 1)) + (check-equal? @honu{1 + 2 * 3} (+ 1 (* 2 3))) + (check-equal? @honu{3 * 2 + 1} (+ (* 3 2) 1)) + (check-equal? @honu{1 + 4 ^ 2 * 3} (+ 1 (* (expt 4 2) 3))) + (check-equal? @honu{1 + 4 ^ 3 ^ 2} (+ 1 (expt 4 (expt 3 2)))) + (check-equal? @honu{4 ^ 3 ^ 2 + 1} (+ (expt 4 (expt 3 2)) 1)) - (check-equal? (honu @input{ + (check-equal? @honu{ var n = 5 cond n < 10: 'x1, n > 10: 'x2 - }) + } 'x1) - (check-equal? (honu @input{ + (check-equal? @honu{ if (2 > 1) 1 else 0 - }) + } 1) - (check-equal? (honu @input{[x + 1: x = [1, 2, 3]]}) '(2 3 4)) - (check-equal? (honu @input{[x + y: x = [1, 2, 3], y = [4, 5, 6]]}) '(5 7 9)) + (check-equal? @honu{[x + 1: x = [1, 2, 3]]} '(2 3 4)) + (check-equal? @honu{[x + y: x = [1, 2, 3], y = [4, 5, 6]]} '(5 7 9)) ) (honu-tests - (check-equal? (honu @input{function foo(x){ + (check-equal? @honu{function foo(x){ x * 2 } foo(5) - }) + } 10))