Skip to content

Commit

Permalink
Add some tests for racket/htdp#229
Browse files Browse the repository at this point in the history
  • Loading branch information
shhyou committed Oct 24, 2024
1 parent 651e1f1 commit 046311b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions drracket-test/tests/drracket/module-lang-test.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ f: contract violation
#rx"Ran 1 test.\n0 tests passed."
#|
check-expect encountered the following error instead of the expected value, 7.
:: at line 3, column 0 first argument of equality cannot be a function, given (lambda (a1) ...)
:: at line 3, column 0 first argument of equality cannot be a function, given posn-x
at line 3, column 0
|#
#:extra-assert
Expand All @@ -598,15 +598,15 @@ f: contract violation
(pregexp
(string-append
"check-expect[ a-z]+error.*[^\n]+\n"
".*::.*at line 3, column 0 first argument.*function[^\n]*\n"
".*::.*at line 3, column 0 first argument.*function.*given posn-x[^\n]*\n"
"at line 3, column 0")))
;; Includes the flattened test result snips.
(define full-ints-text
(send ints get-text (send ints paragraph-start-position 2) 'eof #t))
(define passed?
(regexp-match? re full-ints-text))
(unless passed?
(eprintf "FAILED line ~a: ~a\n expected: ~s\n\n got: ~a\n"
(eprintf "FAILED line ~a: ~a\n extra assertion expected: ~s\n\n got: ~a\n"
(test-line test)
(test-definitions test)
re
Expand Down Expand Up @@ -665,6 +665,20 @@ f: contract violation
;; ^ check-within is highlighted
)))

(test @t{
#lang htdp/isl+
(define (my-add1 n) (+ n 1))
my-add1
(check-expect my-add1 2)
}
#f
#rx"^my-add1\nRan 1 test[.]\n0 tests passed[.]"
#:extra-assert
(λ (defs ints)
(regexp-match? #px"::\\s+at line 4, column 0[^\n]+function[^\n]+given my-add1"
;; Includes the flattened test result snips.
(send ints get-text (send ints paragraph-start-position 2) 'eof #t))))

(fire-up-drracket-and-run-tests run-test)

;; Test mode:
Expand Down

0 comments on commit 046311b

Please sign in to comment.