| 
3152 | 3152 |        (newline op)  | 
3153 | 3153 |        0])))  | 
3154 | 3154 | 
 
  | 
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)  | 
3156 | 3163 |   (define (print-derivation-error d)  | 
3157 | 3164 |     (parameterize ([pretty-print-print-line (derivation-pretty-printer "    ")])  | 
3158 | 3165 |       (pretty-print d (current-error-port))))  | 
 | 3166 | +  (define (checkable-derivation d)  | 
 | 3167 | +    (equal? jf (car (derivation-term d))))  | 
3159 | 3168 |   (let loop ([d d])  | 
3160 | 3169 |     (let ([ls (derivation-subs d)])  | 
3161 | 3170 |       (for ([d ls])  | 
3162 | 3171 |         (unless (loop d)  | 
3163 | 3172 |           (print-derivation-error d)))  | 
3164 |  | -      (unless (f d)  | 
 | 3173 | +      (unless (if (checkable-derivation d)  | 
 | 3174 | +                  (f d)  | 
 | 3175 | +                  #t)  | 
3165 | 3176 |         (print-derivation-error d)))))  | 
3166 | 3177 | 
 
  | 
3167 | 3178 | (define (test-modeless-jf/proc jf jf-pred derivation val srcinfo)  | 
 | 
3176 | 3187 |        (pretty-print derivation (current-error-port)))  | 
3177 | 3188 |      (when (not (null? (derivation-subs derivation)))  | 
3178 | 3189 |        (eprintf"  because the following sub-derivations fail:\n")  | 
3179 |  | -       (print-failing-subderivations jf-pred derivation))]))  | 
 | 3190 | +       (print-failing-subderivations jf jf-pred derivation))]))  | 
3180 | 3191 | 
 
  | 
3181 | 3192 | (define (test-judgment-holds/proc thunk name lang pat srcinfo is-relation?)  | 
3182 | 3193 |   (define results (thunk))  | 
 | 
0 commit comments