From df019df8a3c18c3a8f25f8b5872acfeebf57d983 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Fri, 2 Oct 2015 19:54:20 -0400 Subject: [PATCH] A few more tests --- remix/exp/reader.rkt | 53 +++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/remix/exp/reader.rkt b/remix/exp/reader.rkt index b468fbd..af88519 100644 --- a/remix/exp/reader.rkt +++ b/remix/exp/reader.rkt @@ -1,33 +1,50 @@ #lang racket/base -read-accept-dot -read-accept-infix-dot +(define STX? #f) -(define (read-remix) +(define (remix-f f) (parameterize ([read-square-bracket-as-paren #f] [read-curly-brace-as-paren #f] [read-square-bracket-with-tag #t] - [read-curly-brace-with-tag #t]) - (read))) + [read-curly-brace-with-tag #t] + [read-accept-dot #f] + [read-accept-infix-dot #f] + [read-cdot #t]) + (f))) + +(define (remix-read) (remix-f read)) +(define (remix-read-syntax) (remix-f read-syntax)) (module+ test (require rackunit racket/port) (define-syntax-rule (testit* t ...) (begin (testit . t) ...)) + (define-syntax-rule (testit str d) + (testit-f str 'd #'d)) + + (define (testit-f str qd stx) + (check-equal? (with-input-from-string str remix-read) qd) + (when STX? + (check-equal? (with-input-from-string str remix-read-syntax) stx))) - (define (testit str qd) - (check-equal? (with-input-from-string str read-remix) qd)) + (check-false (read-square-bracket-with-tag)) + (check-false (read-curly-brace-with-tag)) + (check-false (read-cdot)) (testit* - ["[1 2 3]" '(#%brackets 1 2 3)] - ["{1 2 3}" '(#%braces 1 2 3)] - ["a.b" '(#%dot a b)] - ["1.a" '(#%dot 1 a)] - ["1.2.a" '(#%dot 1.2 a)] - ["a.1.2" '(#%dot a 1.2)] - ["a.b.c" '(#%dot a (#%dot b c))] - ["a.(b c)" '(#%dot a (b c))] - ["(a b).c" '(#%dot (a b) c)] - ["(a b).(c d)" '(#%dot (a b) (c d))] - ["(a b).[3]" '(#%dot (a b) (#%brackets 3))])) + ["[1 2 3]" (#%brackets 1 2 3)] + ["{1 2 3}" (#%braces 1 2 3)] + ["a.b" (#%dot a b)] + ["a .b" (#%dot a b)] + ["a. b" (#%dot a b)] + ["a . b" (#%dot a b)] + ["1.a" (#%dot 1 a)] + ["1.2.a" (#%dot 1.2 a)] + ["1 .2.a" (#%dot 1 (#%dot 2 a))] + ["a.1.2" (#%dot a 1.2)] + ["a.b.c" (#%dot a (#%dot b c))] + ["a.(b c)" (#%dot a (b c))] + ["(a b).c" (#%dot (a b) c)] + ["(a b).(c d)" (#%dot (a b) (c d))] + ["(a b).[3]" (#%dot (a b) (#%brackets 3))]))