Skip to content

Commit c3bfe1d

Browse files
committed
Only report proper sub-derivations from test-judgment-holds
1 parent dec519a commit c3bfe1d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

redex-lib/redex/private/reduction-semantics.rkt

+14-3
Original file line numberDiff line numberDiff line change
@@ -3152,16 +3152,27 @@
31523152
(newline op)
31533153
0])))
31543154

3155-
(define (print-failing-subderivations f d)
3155+
;; Takes a judgment-form name `jf`, a sub-derivation predicate for testing whether a
3156+
;; sub-derivation of `jf` is valid.
3157+
;; The derivation predicate will only be called on sub-derivations of the
3158+
;; judgment `jf`.
3159+
;; Sub-derivations from other judgments get ignored.
3160+
;; TODO: Can we create a generic sub-derivation checker that does not,
3161+
;; statically, know the name of the judgment it is checking?
3162+
(define (print-failing-subderivations jf f d)
31563163
(define (print-derivation-error d)
31573164
(parameterize ([pretty-print-print-line (derivation-pretty-printer " ")])
31583165
(pretty-print d (current-error-port))))
3166+
(define (checkable-derivation d)
3167+
(equal? jf (car (derivation-term d))))
31593168
(let loop ([d d])
31603169
(let ([ls (derivation-subs d)])
31613170
(for ([d ls])
31623171
(unless (loop d)
31633172
(print-derivation-error d)))
3164-
(unless (f d)
3173+
(unless (if (checkable-derivation d)
3174+
(f d)
3175+
#t)
31653176
(print-derivation-error d)))))
31663177

31673178
(define (test-modeless-jf/proc jf jf-pred derivation val srcinfo)
@@ -3176,7 +3187,7 @@
31763187
(pretty-print derivation (current-error-port)))
31773188
(when (not (null? (derivation-subs derivation)))
31783189
(eprintf" because the following sub-derivations fail:\n")
3179-
(print-failing-subderivations jf-pred derivation))]))
3190+
(print-failing-subderivations jf jf-pred derivation))]))
31803191

31813192
(define (test-judgment-holds/proc thunk name lang pat srcinfo is-relation?)
31823193
(define results (thunk))

redex-test/redex/tests/tl-test.rkt

-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@
250250
(list))))))
251251
(regexp
252252
(regexp-quote "because the following sub-derivations fail:
253-
(derivation '(J1 1 x) \"Base\" '())
254253
(derivation
255254
'(J2 (1 x) 1)
256255
\"Pair\"

0 commit comments

Comments
 (0)