www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

test-split.rkt (1101B)


      1 #lang type-expander
      2 
      3 (require phc-adt phc-toolkit)
      4 (adt-init)
      5 
      6 (define-tagged foo [a : 'a1] [b : 'b1] [c : 'c1])
      7 (define-tagged bar [a : 'a2] [b : 'b2] [c : 'c2])
      8 (define-tagged baz [a : 'a3] [b : 'b3])
      9 (define-tagged qux           [b : 'b4] [d : 'd4])
     10 
     11 (let-values ([(x y) (split (foo 'a1 'b1 'c1) : (U (foo a b c)) b)])
     12   (check-equal?: x : (tagged foo [b 'b1]) (tagged foo [b 'b1]))
     13   (check-equal?: y : (tagged foo [a 'a1] [c 'c1]) (tagged foo [a 'a1] [c 'c1])))
     14 
     15 (let-values ([(x y) (split (bar 'a2 'b2 'c2) : (U (foo a b c) (bar a b c)) b)])
     16   (check-equal?: x : (tagged bar [b 'b2]) (tagged bar [b 'b2]))
     17   (check-equal?: y : (tagged bar [a 'a2] [c 'c2]) (tagged bar [a 'a2] [c 'c2])))
     18 
     19 (let-values ([(x y) (split (baz 'a3 'b3) : (U (foo a b c) (baz a b)) b)])
     20   (check-equal?: x : (tagged baz [b 'b3]) (tagged baz [b 'b3]))
     21   (check-equal?: y : (tagged baz [a 'a3]) (tagged baz [a 'a3])))
     22 
     23 (let-values ([(x y) (split (qux 'b4 'd4) : (U (foo a b c) (qux b d)) b)])
     24   (check-equal?: x : (tagged qux [b 'b4]) (tagged qux [b 'b4]))
     25   (check-equal?: y : (tagged qux [d 'd4]) (tagged qux [d 'd4])))