Skip to content

Commit 905b8b7

Browse files
committed
Documentation for test-judgment-holds with sub-derivation reporting
1 parent 2807a59 commit 905b8b7

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

redex-doc/redex/scribblings/ref/testing.scrbl

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,51 @@ relation @racket[rel-expr] to a term specified by @racket[goal-expr] in
153153

154154
(test-results)]
155155

156-
@defform*[((test-judgment-holds (judgment-form-or-relation pat/term ...))
157-
(test-judgment-holds modeless-judgment-form derivation-expr))]{
156+
@defform*/subs[((test-judgment-holds (judgment-form-or-relation pat/term ...) mutuals)
157+
(test-judgment-holds modeless-judgment-form derivation-expr))
158+
([mutuals (code:line)
159+
(code:line #:mutuals (judgment-form-id ...))])]{
158160
In the first form, tests to see if @racket[(judgment-form-or-relation pat/term ...)] holds.
159161
In the second form, tests to see if the result of @racket[derivation-expr] is a derivation and,
160162
if so, that it is derivable using @racket[modeless-judgment-form].
163+
164+
For modeless judgments, if the derivation is invalid, the test will report the
165+
all the proper sub-derivations of @racket[modeless-judgment-form] that fail to hold.
166+
If @racket[modeless-judgment-form] has other judgment premises, these
167+
identifiers can be supplied in the optional #racket[#:mutuals] arguments, and
168+
the form will report each invalid sub-derivations from all the specified judgment forms.
169+
170+
@examples[
171+
#:eval redex-eval
172+
(define-language L)
173+
(define-judgment-form L
174+
[----------- "Base"
175+
(J1 natural 1)])
176+
177+
(define-judgment-form L
178+
[----------- "Base"
179+
(J2 natural 1)]
180+
181+
[(J1 any_1 any_2)
182+
(J2 any_1 any_3)
183+
-------------- "Pair"
184+
(J2 (any_1 any_2) any_3)])
185+
186+
(test-judgment-holds J2 (derivation `(J2 (1 x) 1) "Pair"
187+
(list
188+
(derivation `(J1 1 x) "Base"
189+
(list))
190+
(derivation `(J2 1 1) "Base"
191+
(list)))))
192+
193+
(test-judgment-holds J2 (derivation `(J2 (1 x) 1) "Pair"
194+
(list
195+
(derivation `(J1 1 x) "Base"
196+
(list))
197+
(derivation `(J2 1 1) "Base"
198+
(list))))
199+
#:mutuals (J1))
200+
]
161201
}
162202

163203
@defform[(test-predicate p? e)]{

0 commit comments

Comments
 (0)