Skip to content

Commit

Permalink
Avoid leaking p? in check-satisfied to anonymous λ
Browse files Browse the repository at this point in the history
  • Loading branch information
shhyou committed Dec 27, 2024
1 parent 495e6bd commit ef67552
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion htdp-lib/test-engine/racket-tests.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@
(list code name)
'comes-from-check-satisfied))]
[(_ actual:exp expected-predicate:exp)
(let ([pred #`(let ([p? expected-predicate:exp])
(let ([pred #`(let ([p? #,(syntax-property #'expected-predicate:exp
'inferred-name (void))])
(let ((name (object-name p?)))
(unless (and (procedure? p?) (procedure-arity-includes? p? 1))
(if name ;; this produces the BSL/ISL name

This comment has been minimized.

Copy link
@shhyou

shhyou Dec 27, 2024

Author Collaborator

Unfortunately, name is always non-#false because all lambdas have source-location-based names (path/file.rkt:LL:CC). What really needs to be fixed os for error-check to use print-convert to format procedural values.

Expand Down
14 changes: 14 additions & 0 deletions htdp-test/tests/test-engine/racket-tests.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@
unequal-actual 1
unequal-expected 2)

(check-satisfied 0 (lambda (n bad) #t))
(check-exn
(lambda (e)
(initialize-test-object!)
(and (exn:fail:contract? e)
(regexp-match?
;; BUG: error-check in test-engine/racket-tests is NOT using print-convert!
(pregexp
(string-append "check-satisfied.*expect.*one argument.*second position.*"
"Given.*racket-tests[.]rkt:[[:digit:]]+:[[:digit:]]+"))
(exn-message e))))
(lambda ()
(run-tests!)))

(check-within 1.345 1.3 .05)
(check-success)

Expand Down

0 comments on commit ef67552

Please sign in to comment.