added a test--> that only does a single step of the reduction relation

svn: r14014
This commit is contained in:
Robby Findler 2009-03-08 21:07:01 +00:00
parent 1e807c3a33
commit fe618071dc
6 changed files with 51 additions and 7 deletions

View File

@ -5,4 +5,3 @@
(provide (all-from-out "reduction-semantics.ss" (provide (all-from-out "reduction-semantics.ss"
"gui.ss" "gui.ss"
"pict.ss")) "pict.ss"))
(provide render-language)

View File

@ -1875,12 +1875,20 @@
(define-syntax (test-->> stx) (define-syntax (test-->> stx)
(syntax-case stx () (syntax-case stx ()
[(_ red #:cycles-ok e1 e2 ...) [(_ red #:cycles-ok e1 e2 ...)
#`(test-->>/procs red e1 (list e2 ...) #t #,(get-srcloc stx))] #`(test-->>/procs red e1 (list e2 ...) apply-reduction-relation*/cycle? #t #,(get-srcloc stx))]
[(_ red e1 e2 ...) [(_ red e1 e2 ...)
#`(test-->>/procs red e1 (list e2 ...) #f #,(get-srcloc stx))])) #`(test-->>/procs red e1 (list e2 ...) apply-reduction-relation*/cycle? #f #,(get-srcloc stx))]))
(define (test-->>/procs red arg expected cycles-ok? srcinfo) (define-syntax (test--> stx)
(let-values ([(got got-cycle?) (apply-reduction-relation*/cycle? red arg)]) (syntax-case stx ()
[(_ red e1 e2 ...)
#`(test-->>/procs red e1 (list e2 ...) apply-reduction-relation/dummy-second-value #t #,(get-srcloc stx))]))
(define (apply-reduction-relation/dummy-second-value red arg)
(values (apply-reduction-relation red arg) #f))
(define (test-->>/procs red arg expected apply-red cycles-ok? srcinfo)
(let-values ([(got got-cycle?) (apply-red red arg)])
(inc-tests) (inc-tests)
(cond (cond
@ -1992,6 +2000,7 @@
test-equal test-equal
test-->> test-->>
test-->
test-predicate test-predicate
test-results) test-results)

View File

@ -1446,4 +1446,29 @@
(test (capture-output (test-->> red-cycle (term a)) (test-results)) (test (capture-output (test-->> red-cycle (term a)) (test-results))
#rx"FAILED tl-test.ss:[0-9.]+\nfound a cycle in the reduction graph\n1 test failed \\(out of 1 total\\).\n")) #rx"FAILED tl-test.ss:[0-9.]+\nfound a cycle in the reduction graph\n1 test failed \\(out of 1 total\\).\n"))
(let ()
(define-metafunction empty-language [(f any) ((any))])
(test (capture-output (test-equal (term (f 1)) (term ((1))))
(test-results))
"One test passed.\n"))
(let ()
(test (capture-output (test-predicate odd? 1)
(test-results))
"One test passed.\n"))
(let ()
(define red (reduction-relation empty-language (--> any (any))))
(test (capture-output (test--> red (term (1 2 3)) (term ((1 2 3)))) (test-results))
"One test passed.\n"))
(let ()
(define red (reduction-relation empty-language
(--> any (any))
(--> (any) any)))
(test (capture-output (test--> red (term (x)) (term ((x))) (term x)) (test-results))
"One test passed.\n")
(test (capture-output (test--> red (term (x)) (term x) (term ((x)))) (test-results))
"One test passed.\n"))
(print-tests-passed 'tl-test.ss)) (print-tests-passed 'tl-test.ss))

View File

@ -1005,6 +1005,13 @@ reduces to the @scheme[e2]s under @scheme[reduction-relation]
(using @scheme[apply-reduction-relation*], so it may not terminate). (using @scheme[apply-reduction-relation*], so it may not terminate).
} }
@defform[(test--> reduction-relation e1 e2 ...)]{
Tests to see if the value of @scheme[e1] (which should be a term),
reduces to the @scheme[e2]s in a single step, under @scheme[reduction-relation]
(using @scheme[apply-reduction-relation]).
}
@defform[(test-predicate p? e)]{ @defform[(test-predicate p? e)]{
Tests to see if the value of @scheme[e] matches the predicate @scheme[p?]. Tests to see if the value of @scheme[e] matches the predicate @scheme[p?].
} }

View File

@ -38,6 +38,7 @@
test-equal test-equal
test-->> test-->>
test-->
test-predicate test-predicate
test-results) test-results)

View File

@ -2,10 +2,13 @@ v4.1.5
* renamed test--> to test-->> * renamed test--> to test-->>
* added #:cycles-ok flag to (what is now called) test-->>. * added a new test--> that only tests for a single step in the
reduction sequence
* added #:cycles-ok flag to (what is now called) test-->>
* define-metafunction and reduction-relation now work better with * define-metafunction and reduction-relation now work better with
Check Syntax, as Check Syntax
* added the #:arrow keyword to reduction-relation, which lets you use * added the #:arrow keyword to reduction-relation, which lets you use
a different main arrow (mostly useful for the typesetting) a different main arrow (mostly useful for the typesetting)