Skip to content

Commit 3944db1

Browse files
committed
Unbreak test-engine tests in DrRacket
As per e-mail discussion with jbclements, shhyou, mfelleisen.
1 parent 6e14fa5 commit 3944db1

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

htdp-test/tests/test-engine/racket-tests.rkt

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
(only-in htdp/bsl/runtime configure)
1313
(except-in rackunit check-within)
1414
racket/port
15+
(only-in racket/string string-contains?)
1516
simple-tree-text-markup/text
1617
test-engine/racket-tests
1718
test-engine/test-engine)
@@ -265,24 +266,27 @@
265266
(check-error (empty) "function call: expected a function after the open parenthesis, but received '()")
266267
(check-success)
267268

269+
(define (markup-message-matcher message)
270+
(lambda (m)
271+
(define markup-message (with-output-to-string
272+
(lambda () (display-markup m))))
273+
;; From the command line, tests/test-engine/racket-tests[.]rkt is
274+
;; in the error message
275+
(and (string-contains? markup-message "racket-tests.rkt")
276+
(string-contains? markup-message message))))
277+
268278
;; rational: x is unbound so this check-error shall not pass
269279
;; (but it also should not raise the syntax error immediately at expansion)
270280
(check-error x "x: this variable is not defined")
271281
(check-failure unexpected-error?
272282
unexpected-error-exn exn:fail:syntax?
273283
unexpected-error-expected "x: this variable is not defined"
274284
unexpected-error/markup-error-markup
275-
(lambda (m)
276-
(regexp-match?
277-
;; From the command line, tests/test-engine/racket-tests[.]rkt is
278-
;; in the error message
279-
;;
280-
;; Ideally, we want to see the message "x: this variable is not defined" in
281-
;; the exception. Unfortunately, the #%top binding is not from *sl.
282-
#rx"x: unbound identifier.*tests/test-engine/racket-tests[.]rkt"
283-
(with-output-to-string
284-
(lambda () (display-markup m))))))
285-
285+
;; Ideally, we want to see the message "x: this variable is not defined" in
286+
;; the exception. Unfortunately, the #%top binding is not from *sl.
287+
(markup-message-matcher "x: unbound identifier"))
288+
289+
286290
(check-error (#%app/isl 123) "function call: expected a function after the open parenthesis, but received 123")
287291
(check-success)
288292

@@ -291,26 +295,16 @@
291295
unexpected-error-exn exn:fail:syntax?
292296
unexpected-error-expected "function call: expected a function after the open parenthesis, but found a number"
293297
unexpected-error/markup-error-markup
294-
(lambda (m)
295-
(regexp-match?
296-
;; From the command line, tests/test-engine/racket-tests[.]rkt is
297-
;; in the error message
298-
#rx"function call: expected a function after the open parenthesis, but found a number.*tests/test-engine/racket-tests[.]rkt"
299-
(with-output-to-string
300-
(lambda () (display-markup m))))))
298+
(markup-message-matcher
299+
"function call: expected a function after the open parenthesis, but found a number"))
301300

302301
(check-error define/isl "define: expected an open parenthesis before define, but found none")
303302
(check-failure unexpected-error?
304303
unexpected-error-exn exn:fail:syntax?
305304
unexpected-error-expected "define: expected an open parenthesis before define, but found none"
306305
unexpected-error/markup-error-markup
307-
(lambda (m)
308-
(regexp-match?
309-
;; From the command line, tests/test-engine/racket-tests[.]rkt is
310-
;; in the error message
311-
#rx"define: expected an open parenthesis before define, but found none.*tests/test-engine/racket-tests[.]rkt"
312-
(with-output-to-string
313-
(lambda () (display-markup m))))))
306+
(markup-message-matcher
307+
"define: expected an open parenthesis before define, but found none"))
314308

315309
(define (create n)
316310
(make-ball n n 'blue))

0 commit comments

Comments
 (0)