From 3ded9ea003174a9ce24d32f4c7be00bc950276a6 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Tue, 10 Jun 2014 12:49:36 -0400 Subject: [PATCH] fixed the ~e sensitive test --- pkgs/plai/tests/datatype.rkt | 58 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/pkgs/plai/tests/datatype.rkt b/pkgs/plai/tests/datatype.rkt index 9460069c8b..20de5126a6 100644 --- a/pkgs/plai/tests/datatype.rkt +++ b/pkgs/plai/tests/datatype.rkt @@ -29,34 +29,42 @@ (define-type t1 (c1 (n number?))) +(define ((ERR f) line#) + (format f (+ line# THIS-LINE#))) + +(define ERR1 + (ERR "\\(exception \\(make-i #f\\) \"make-i.+\" ' \"at line ~a\"\\)")) + +(define ERR2 + (ERR "\\(exception \\(i-f #f\\) \"i-f.+\" ' \"at line ~a\"\\)")) + +(define ERR3 + (ERR + "\\(exception \\(c1 \\(quote not-a-number\\)\\) \"c1.+\" ' \"at line ~a\"\\)")) + +(define (ERR4 line#) + (string-append + (regexp-quote "(exception (type-case t (list 1) (c () 1)) \"") + (regexp-quote "type-case: expected a value from type t, got: '(1)\"") + (regexp-quote " ' \"at line ") + ((ERR "~a") line#) + (regexp-quote "\")"))) + +(define THIS-LINE# 53) + (eli:test (i 4) - - (regexp-match "\\(exception \\(make-i #f\\) \"make-i.+\" ' \"at line 36\"\\)" - (with-both-output-to-string (λ () (test/exn (make-i #f) "contract")))) - - (regexp-match "\\(exception \\(i-f #f\\) \"i-f.+\" ' \"at line 39\"\\)" - (with-both-output-to-string (λ () (test/exn (i-f #f) "contract")))) - - - (type-case A (mta) - [mta () 1] - [a (x) 2]) + (regexp-match (ERR1 4) (with-both-output-to-string (λ () (test/exn (make-i #f) "contract")))) + (regexp-match (ERR2 5) (with-both-output-to-string (λ () (test/exn (i-f #f) "contract")))) + (type-case A (mta) [mta () 1] [a (x) 2]) => 1 + (regexp-match (ERR3 9) (with-both-output-to-string (λ () (test (c1 'not-a-number) (list 5))))) - (regexp-match "\\(exception \\(c1 \\(quote not-a-number\\)\\) \"c1.+\" ' \"at line 49\"\\)" - (with-both-output-to-string (λ () (test (c1 'not-a-number) (list 5))))) - - (regexp-match (regexp-quote "(exception (type-case t (list 1) (c () 1)) \"type-case: expected a value from type t, got: (1)\" ' \"at line 53\")") - (with-both-output-to-string (λ () - (test/exn - (type-case t (list 1) (c () 1)) - "expected")))) - - (type-case "foo" "bar") =error> "this must be a type defined with define-type" - - (type-case + "bar") =error> "this must be a type defined with define-type" + (regexp-match + (ERR4 (+ 12 1)) + (with-both-output-to-string (λ () (test/exn (type-case t (list 1) (c () 1)) "expected")))) - (type-case #f [x () 1]) =error> "this must be a type defined with define-type" - ) + (type-case "foo" "bar") =error> "this must be a type defined with define-type" + (type-case + "bar") =error> "this must be a type defined with define-type" + (type-case #f [x () 1]) =error> "this must be a type defined with define-type")