|
3072 | 3072 | "expected a modeless judgment-form" |
3073 | 3073 | #'jf)) |
3074 | 3074 | #`(let ([derivation e]) |
3075 | | - (test-modeless-jf/proc 'jf derivation (judgment-holds jf derivation) #,(get-srcloc stx)))] |
| 3075 | + (test-modeless-jf/proc 'jf (lambda (x) (judgment-holds jf x)) derivation (judgment-holds jf derivation) #,(get-srcloc stx)))] |
3076 | 3076 | [(_ (jf . rest)) |
3077 | 3077 | (unless (judgment-form-id? #'jf) |
3078 | 3078 | (raise-syntax-error 'test-judgment-holds |
|
3141 | 3141 | ;; this case should always result in a syntax error |
3142 | 3142 | #`(judgment-holds #,orig-jf-stx)])])) |
3143 | 3143 |
|
3144 | | -(define (test-modeless-jf/proc jf derivation val srcinfo) |
| 3144 | +(define (derivation-pretty-printer pad) |
| 3145 | + (λ (new-line-number op old-len col) |
| 3146 | + (cond |
| 3147 | + [(number? new-line-number) |
| 3148 | + (unless (= new-line-number 0) (newline op)) |
| 3149 | + (display pad op) |
| 3150 | + 2] |
| 3151 | + [else |
| 3152 | + (newline op) |
| 3153 | + 0]))) |
| 3154 | + |
| 3155 | +(define (print-failing-subderivations f d) |
| 3156 | + (define (print-derivation-error d) |
| 3157 | + (parameterize ([pretty-print-print-line (derivation-pretty-printer " ")]) |
| 3158 | + (pretty-print d (current-error-port)))) |
| 3159 | + (let loop ([d d]) |
| 3160 | + (let ([ls (derivation-subs d)]) |
| 3161 | + (for ([d ls]) |
| 3162 | + (unless (loop d) |
| 3163 | + (print-derivation-error d))) |
| 3164 | + (unless (f d) |
| 3165 | + (print-derivation-error d))))) |
| 3166 | + |
| 3167 | +(define (test-modeless-jf/proc jf jf-pred derivation val srcinfo) |
3145 | 3168 | (cond |
3146 | 3169 | [val |
3147 | 3170 | (inc-successes)] |
3148 | 3171 | [else |
3149 | 3172 | (inc-failures) |
3150 | 3173 | (print-failed srcinfo) |
3151 | 3174 | (eprintf " derivation does not satisfy ~a\n" jf) |
3152 | | - (parameterize ([pretty-print-print-line |
3153 | | - (λ (new-line-number op old-len col) |
3154 | | - (cond |
3155 | | - [(number? new-line-number) |
3156 | | - (unless (= new-line-number 0) (newline op)) |
3157 | | - (display " " op) |
3158 | | - 2] |
3159 | | - [else |
3160 | | - (newline op) |
3161 | | - 0]))]) |
3162 | | - (pretty-print derivation (current-error-port)))])) |
| 3175 | + (parameterize ([pretty-print-print-line (derivation-pretty-printer " ")]) |
| 3176 | + (pretty-print derivation (current-error-port))) |
| 3177 | + (when (not (null? (derivation-subs derivation))) |
| 3178 | + (eprintf" because the following sub-derivations fail:\n") |
| 3179 | + (print-failing-subderivations jf-pred derivation))])) |
3163 | 3180 |
|
3164 | 3181 | (define (test-judgment-holds/proc thunk name lang pat srcinfo is-relation?) |
3165 | 3182 | (define results (thunk)) |
|
0 commit comments