Move tests together

This commit is contained in:
Tony Garnock-Jones 2014-05-13 19:35:03 -04:00
parent 8011a7263c
commit 67d1b3b6db
1 changed files with 11 additions and 9 deletions

View File

@ -99,15 +99,6 @@
[(? hash?) (error 'pattern->matcher "Cannot match on hash tables at present")]
[other (rseq other acc)])))
(module+ test
(define (E . vs) (hash EOS (apply set vs)))
(check-equal? (pattern->matcher 'A 123) (hash 123 (E 'A)))
(check-equal? (pattern->matcher 'A (cons 1 2)) (hash SOP (hash 1 (hash 2 (hash EOS (E 'A))))))
(check-equal? (pattern->matcher 'A (cons ? 2)) (hash SOP (hash ? (hash 2 (hash EOS (E 'A))))))
(check-equal? (pattern->matcher 'A SOP) (hash struct:start-of-pair (hash EOS (E 'A))))
(check-equal? (pattern->matcher 'A ?) (hash ? (E 'A)))
)
(define (rlookup r key)
(hash-ref r key (lambda () #f)))
@ -364,6 +355,17 @@
[(wildcard-sequence m1) (wildcard-sequence (walk m1))]
[(? hash?) (for/hash [((k v) (in-hash m))] (values k (walk v)))])))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module+ test
(define (E . vs) (hash EOS (apply set vs)))
(check-equal? (pattern->matcher 'A 123) (hash 123 (E 'A)))
(check-equal? (pattern->matcher 'A (cons 1 2)) (hash SOP (hash 1 (hash 2 (hash EOS (E 'A))))))
(check-equal? (pattern->matcher 'A (cons ? 2)) (hash SOP (hash ? (hash 2 (hash EOS (E 'A))))))
(check-equal? (pattern->matcher 'A SOP) (hash struct:start-of-pair (hash EOS (E 'A))))
(check-equal? (pattern->matcher 'A ?) (hash ? (E 'A)))
)
(module+ test
(define (pretty-print-matcher m [port (current-output-port)])
(define (d x) (display x port))