|
12 | 12 | (only-in htdp/bsl/runtime configure) |
13 | 13 | (except-in rackunit check-within) |
14 | 14 | racket/port |
| 15 | + (only-in racket/string string-contains?) |
15 | 16 | simple-tree-text-markup/text |
16 | 17 | test-engine/racket-tests |
17 | 18 | test-engine/test-engine) |
|
265 | 266 | (check-error (empty) "function call: expected a function after the open parenthesis, but received '()") |
266 | 267 | (check-success) |
267 | 268 |
|
| 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 | + |
268 | 278 | ;; rational: x is unbound so this check-error shall not pass |
269 | 279 | ;; (but it also should not raise the syntax error immediately at expansion) |
270 | 280 | (check-error x "x: this variable is not defined") |
271 | 281 | (check-failure unexpected-error? |
272 | 282 | unexpected-error-exn exn:fail:syntax? |
273 | 283 | unexpected-error-expected "x: this variable is not defined" |
274 | 284 | 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 | + |
286 | 290 | (check-error (#%app/isl 123) "function call: expected a function after the open parenthesis, but received 123") |
287 | 291 | (check-success) |
288 | 292 |
|
|
291 | 295 | unexpected-error-exn exn:fail:syntax? |
292 | 296 | unexpected-error-expected "function call: expected a function after the open parenthesis, but found a number" |
293 | 297 | 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")) |
301 | 300 |
|
302 | 301 | (check-error define/isl "define: expected an open parenthesis before define, but found none") |
303 | 302 | (check-failure unexpected-error? |
304 | 303 | unexpected-error-exn exn:fail:syntax? |
305 | 304 | unexpected-error-expected "define: expected an open parenthesis before define, but found none" |
306 | 305 | 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")) |
314 | 308 |
|
315 | 309 | (define (create n) |
316 | 310 | (make-ball n n 'blue)) |
|
0 commit comments