phc-adt/phc-adt-test/phc-adt/test/row-polymorphism/test-with-update-only.rkt
2017-04-27 23:36:19 +02:00

65 lines
3.7 KiB
Racket

#lang type-expander
(require phc-adt phc-toolkit)
(adt-init)
;; Correctly gave an error:
(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)))
: (tagged foo [b 'b1])
(tagged foo [b 'b1]))
;(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)) [a 'a1])
; : (tagged foo [a 'a1] [b 'b1])
; (tagged foo [a 'a1] [b 'b1]))
;(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)) [a 'a1] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1] [c 'c1])
; (tagged foo [a 'a1] [b 'b1] [c 'c1]))
;(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)) [a 'a1] [b 'b1-update])
; : (tagged foo [a 'a1] [b 'b1-update])
; (tagged foo [a 'a1] [b 'b1-update]))
(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)) [b 'b1-update])
: (tagged foo [b 'b1-update])
(tagged foo [b 'b1-update]))
;(check-equal?: (with!! (tagged foo [b 'b1]) : (U (foo b)) [a 'a1] [b 'b1-update] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1-update] [c 'c1])
; (tagged foo [a 'a1] [b 'b1-update] [c 'c1]))
(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)))
: (tagged foo [b 'b1] [d 'd1])
(tagged foo [b 'b1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)) [a 'a1])
; : (tagged foo [a 'a1] [b 'b1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)) [a 'a1] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1] [c 'c1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1] [c 'c1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)) [a 'a1] [b 'b1-update])
; : (tagged foo [a 'a1] [b 'b1-update] [d 'd1])
; (tagged foo [a 'a1] [b 'b1-update] [d 'd1]))
(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)) [b 'b1-update])
: (tagged foo [b 'b1-update] [d 'd1])
(tagged foo [b 'b1-update] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d)) [a 'a1] [b 'b1-update] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1-update] [c 'c1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1-update] [c 'c1] [d 'd1]))
(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)))
: (tagged foo [b 'b1] [d 'd1])
(tagged foo [b 'b1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [a 'a1])
; : (tagged foo [a 'a1] [b 'b1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [a 'a1] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1] [c 'c1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1] [c 'c1] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [a 'a1] [b 'b1-update])
; : (tagged foo [a 'a1] [b 'b1-update] [d 'd1])
; (tagged foo [a 'a1] [b 'b1-update] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [b 'b1-update])
; : (tagged foo [b 'b1-update] [d 'd1])
; (tagged foo [b 'b1-update] [d 'd1]))
;(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [a 'a1] [b 'b1-update] [c 'c1])
; : (tagged foo [a 'a1] [b 'b1-update] [c 'c1] [d 'd1])
; (tagged foo [a 'a1] [b 'b1-update] [c 'c1] [d 'd1]))
(check-equal?: (with!! (tagged foo [b 'b1] [d 'd1]) : (U (foo b d) (foo a d)) [d 'd1-update])
: (tagged foo [b 'b1] [d 'd1-update])
(tagged foo [b 'b1] [d 'd1-update]))