From b175b6e68f8153c1e8d7c846d7265f9c0a2d7973 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Wed, 4 Jan 2017 19:35:43 -0500 Subject: [PATCH] add test for (debug-repl) before initialization of a variable in scope closes #9 --- debug/test/debug-repl.rkt | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/debug/test/debug-repl.rkt b/debug/test/debug-repl.rkt index fd49707..161a093 100644 --- a/debug/test/debug-repl.rkt +++ b/debug/test/debug-repl.rkt @@ -36,3 +36,40 @@ "-> ")) ) +;; test for issue #9 +(test-case "issue #9" + (define (f) + (when #true + (debug-repl)) + (define a 1) + a) + + (let ([i (open-input-string "y b c (+ y b c)")] + [o (open-output-string)]) + (check-equal? (parameterize ([current-input-port i] + [current-output-port o]) + (f)) + 1) + (check-equal? (get-output-string o) + (string-append + "-> " #;y "7\n" + "-> " #;b "8\n" + "-> " #;c "9\n" + "-> " #;(+ y b c) "24\n" + "-> "))) + + (let ([i (open-input-string "y b c (+ y b c) (+ y a b c)")] + [o (open-output-string)]) + (check-exn #rx"a: undefined;\n cannot use before initialization" + (λ () + (parameterize ([current-input-port i] + [current-output-port o]) + (f)))) + (check-equal? (get-output-string o) + (string-append + "-> " #;y "7\n" + "-> " #;b "8\n" + "-> " #;c "9\n" + "-> " #;(+ y b c) "24\n" + "-> " #;(+ y a b c))))) +