|
3060 | 3060 |
|
3061 | 3061 | (define-syntax (test-judgment-holds stx) |
3062 | 3062 | (syntax-parse stx |
3063 | | - [(_ jf e:expr) |
| 3063 | + [(_ jf e:expr (~optional (~seq #:mutuals (mjf:id ...)) |
| 3064 | + #:defaults ([(mjf 1) '()]))) |
3064 | 3065 | (unless (judgment-form-id? #'jf) |
3065 | 3066 | (raise-syntax-error 'test-judgment-holds |
3066 | 3067 | "expected a modeless judgment-form" |
|
3072 | 3073 | "expected a modeless judgment-form" |
3073 | 3074 | #'jf)) |
3074 | 3075 | #`(let ([derivation e]) |
3075 | | - (test-modeless-jf/proc 'jf (lambda (x) (judgment-holds jf x)) derivation (judgment-holds jf derivation) #,(get-srcloc stx)))] |
| 3076 | + (test-modeless-jf/proc 'jf |
| 3077 | + (make-hasheq |
| 3078 | + `((jf . ,(lambda (x) (judgment-holds jf x))) |
| 3079 | + #,@(for/list ([jf (attribute mjf)]) |
| 3080 | + `(,jf . ,#`,(lambda (x) (judgment-holds #,jf x)))))) |
| 3081 | + derivation (judgment-holds jf derivation) |
| 3082 | + #,(get-srcloc stx)))] |
3076 | 3083 | [(_ (jf . rest)) |
3077 | 3084 | (unless (judgment-form-id? #'jf) |
3078 | 3085 | (raise-syntax-error 'test-judgment-holds |
|
3159 | 3166 | ;; Sub-derivations from other judgments get ignored. |
3160 | 3167 | ;; TODO: Can we create a generic sub-derivation checker that does not, |
3161 | 3168 | ;; statically, know the name of the judgment it is checking? |
3162 | | -(define (print-failing-subderivations jf f d) |
| 3169 | +(define (print-failing-subderivations jf jf-pred-hash d) |
3163 | 3170 | (define (print-derivation-error d) |
3164 | 3171 | (parameterize ([pretty-print-print-line (derivation-pretty-printer " ")]) |
3165 | 3172 | (pretty-print d (current-error-port)))) |
3166 | | - (define (checkable-derivation d) |
3167 | | - (equal? jf (car (derivation-term d)))) |
| 3173 | + (define (check-derivation d) |
| 3174 | + (define f (hash-ref jf-pred-hash (car (derivation-term d)) (lambda () #f))) |
| 3175 | + (if f |
| 3176 | + (f d) |
| 3177 | + #t)) |
3168 | 3178 | (let loop ([d d]) |
3169 | 3179 | (let ([ls (derivation-subs d)]) |
3170 | 3180 | (for ([d ls]) |
3171 | 3181 | (unless (loop d) |
3172 | 3182 | (print-derivation-error d))) |
3173 | | - (unless (if (checkable-derivation d) |
3174 | | - (f d) |
3175 | | - #t) |
| 3183 | + (unless (check-derivation d) |
3176 | 3184 | (print-derivation-error d))))) |
3177 | 3185 |
|
3178 | | -(define (test-modeless-jf/proc jf jf-pred derivation val srcinfo) |
| 3186 | +(define (test-modeless-jf/proc jf jf-preds derivation val srcinfo) |
3179 | 3187 | (cond |
3180 | 3188 | [val |
3181 | 3189 | (inc-successes)] |
|
3187 | 3195 | (pretty-print derivation (current-error-port))) |
3188 | 3196 | (when (not (null? (derivation-subs derivation))) |
3189 | 3197 | (eprintf" because the following sub-derivations fail:\n") |
3190 | | - (print-failing-subderivations jf jf-pred derivation))])) |
| 3198 | + (print-failing-subderivations jf jf-preds derivation))])) |
3191 | 3199 |
|
3192 | 3200 | (define (test-judgment-holds/proc thunk name lang pat srcinfo is-relation?) |
3193 | 3201 | (define results (thunk)) |
|
0 commit comments