Skip to content

Commit 3e069f3

Browse files
committed
fix test-->, test-->>, and test-->>∃ so they accept IO judgment forms.
closes #162
1 parent b83be5d commit 3e069f3

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ the comparison. It defaults to @racket[(default-equiv)].
5858
([option (code:line #:cycles-ok)
5959
(code:line #:equiv pred-expr)
6060
(code:line #:pred pred-expr)])
61-
#:contracts ([rel-expr reduction-relation?]
61+
#:contracts ([rel-expr (or/c reduction-relation? IO-judgment-form?)]
6262
[pred-expr (-> any/c any)]
6363
[e1-expr any/c]
6464
[e2-expr any/c])]{
@@ -91,7 +91,7 @@ isn't supplied, then @racket[(default-equiv)] is used.
9191

9292
@defform/subs[(test--> rel-expr option ... e1-expr e2-expr ...)
9393
([option (code:line #:equiv pred-expr)])
94-
#:contracts ([rel-expr reduction-relation?]
94+
#:contracts ([rel-expr (or/c reduction-relation? IO-judgment-form?)]
9595
[pred-expr (-> any/c any/c any/c)]
9696
[e1-expr any/c]
9797
[e2-expr any/c])]{
@@ -124,7 +124,7 @@ step, using @racket[pred-expr] to determine equivalence (or
124124

125125
@defform/subs[(test-->>∃ option ... rel-expr start-expr goal-expr)
126126
([option (code:line #:steps steps-expr)])
127-
#:contracts ([rel-expr reduction-relation?]
127+
#:contracts ([rel-expr (or/c reduction-relation? IO-judgment-form?)]
128128
[start-expr any/c]
129129
[goal-expr (or/c (-> any/c any/c)
130130
(not/c procedure?))]

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,15 +2944,16 @@
29442944
(values (apply-reduction-relation red arg) #f))
29452945

29462946
(define (test-->>/procs name red arg-thnk expected-thnk apply-red cycles-ok? equiv? pred srcinfo)
2947-
(unless (reduction-relation? red)
2948-
(error name "expected a reduction relation as first argument, got ~e" red))
2947+
(unless (or (reduction-relation? red)
2948+
(IO-judgment-form? red))
2949+
(error name "expected a reduction relation or an IO-judgment-form as first argument, got ~e" red))
29492950
(when pred
29502951
(unless (and (procedure? pred)
29512952
(procedure-arity-includes? pred 1))
29522953
(error 'test-->> "expected a procedure that accepted one argument for the #:pred, got ~e"
29532954
pred)))
29542955
(define-values (arg expected)
2955-
(parameterize ([default-language (reduction-relation-lang red)])
2956+
(parameterize ([default-language (reduction-relation/IO-jf-lang red)])
29562957
(values (arg-thnk) (expected-thnk))))
29572958
(define test-failed? #f)
29582959
(define (fail) (inc-failures) (set! test-failed? #t))
@@ -2999,7 +3000,7 @@
29993000
relation
30003001
start:expr
30013002
goal)
3002-
#:declare relation (expr/c #'reduction-relation?
3003+
#:declare relation (expr/c #'(or/c reduction-relation? IO-judgment-form?)
30033004
#:name "reduction relation expression")
30043005
#:declare goal (expr/c #'(or/c (-> any/c any/c) (not/c procedure?))
30053006
#:name "goal expression")

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
(test (capture-output (test-->> red 2 3) (test-results))
3030
#rx"FAILED .*tl-test.(?:.+):[0-9.]+\nexpected: 3\n actual: 2\n1 test failed \\(out of 1 total\\).\n"))
3131

32+
(let ()
33+
(define-judgment-form empty-language #:mode (J I O) [(J 1 2)])
34+
(test (capture-output (test-->> J 1 2) (test-results))
35+
"One test passed.\n")
36+
(test (capture-output (test-->> J 2 3) (test-results))
37+
#rx"FAILED .*tl-test.(?:.+):[0-9.]+\nexpected: 3\n actual: 2\n1 test failed \\(out of 1 total\\).\n"))
38+
3239
(let ()
3340
(define red-share (reduction-relation
3441
empty-language
@@ -208,6 +215,11 @@
208215
(test (capture-output (test--> red (term (1 2 3)) (term ((1 2 3)))) (test-results))
209216
"One test passed.\n"))
210217

218+
(let ()
219+
(define-judgment-form empty-language #:mode (J I O) [(J any (any))])
220+
(test (capture-output (test--> J (term (1 2 3)) (term ((1 2 3)))) (test-results))
221+
"One test passed.\n"))
222+
211223
(let ()
212224
(define red (reduction-relation empty-language
213225
(--> any (any))
@@ -274,7 +286,16 @@
274286
(test (capture-output (test-->>E 1+ 0 7)) "")
275287
(test (capture-output (test-->>∃ #:steps +inf.0 1+ 0 7)) "")
276288
(test (capture-output (test-->>∃ 1+ 0 equal-to-7)) "")
289+
290+
(define-judgment-form L
291+
#:mode (1+/J I O)
292+
[(1+/J number ,(add1 (term number)))])
277293

294+
(test (capture-output (test-->>∃ 1+/J 0 7)) "")
295+
(test (capture-output (test-->>E 1+/J 0 7)) "")
296+
(test (capture-output (test-->>∃ #:steps +inf.0 1+/J 0 7)) "")
297+
(test (capture-output (test-->>∃ 1+/J 0 equal-to-7)) "")
298+
278299
(define identity
279300
(reduction-relation
280301
L
@@ -283,7 +304,7 @@
283304
(test (capture-output (test-->>∃ identity 0 1))
284305
#rx"^FAILED .*\nterm 1 not reachable from 0\n$")
285306

286-
(test (capture-output (test-results)) "2 tests failed (out of 6 total).\n")
307+
(test (capture-output (test-results)) "2 tests failed (out of 10 total).\n")
287308

288309
(test-contract-violation
289310
(test-->>∃ 1+ 0 (λ (x y) x))

0 commit comments

Comments
 (0)