Skip to content

Commit

Permalink
add tests to check known counterexamples to seeming equivalences
Browse files Browse the repository at this point in the history
  • Loading branch information
countvajhula committed Mar 10, 2023
1 parent 6c7aa97 commit bf493da
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion qi-test/tests/flow.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,32 @@
(check-equal? ((☯ (~> (pass positive?) +))
1 -3 5)
6
"runtime arity changes in threading form"))))
"runtime arity changes in threading form"))

(test-suite
"nonlocal semantics"
;; these are collected from counterexamples to candidate equivalences
;; that turned up during code review. They ensure that some tempting
;; "equivalences" that are not really equivalences are formally checked
(let ()
(define-flow g (-< add1 sub1))
(define-flow f positive?)
(define (f* x y) (= (sub1 x) (add1 y)))
(define (amp-pass g f) (☯ (~> (>< g) (pass f) ▽)))
(define (amp-if g f) (☯ (~> (>< (~> g (if f _ ground))) ▽)))
(check-equal? (apply (amp-pass g f) (range -3 4))
(list 1 2 3 1 4 2))
(check-exn exn:fail?
(thunk (apply (amp-if g f) (range -3 4))))
(check-exn exn:fail?
(thunk (apply (amp-pass g f*) (range -3 4))))
(check-equal? (apply (amp-if g f*) (range -3 4))
(list -2 -4 -1 -3 0 -2 1 -1 2 0 3 1 4 2)))
(let ()
(check-equal? ((☯ (~> (>< string->number) (pass _))) "a" "2" "c")
2)
(check-equal? ((☯ (~> (>< (if _ string->number ground)) ▽)) "a" "2" "c")
(list #f 2 #f))))))

(module+ main
(void (run-tests tests)))

0 comments on commit bf493da

Please sign in to comment.