aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/variance.lux
blob: 911c68067636a6f261cf42a54cd941b3e49eed1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(.require
 [library
  [lux (.except)
   ["_" test (.only Test)]
   [abstract
    [monad (.only do)]]
   [math
    ["[0]" random (.only Random)]]]]
 [\\library
  ["[0]" / (.only)
   ["/[1]" // (.only)
    ["[1][0]" check]]]])

(type Super
  (Ex (_ sub) [Text sub]))

(type Sub
  (Super Bit))

(def .public test
  Test
  (<| (_.covering /._)
      (all _.and
           (_.coverage [/.Co]
             (and (//check.subsumes? (type_literal (/.Co Super)) (type_literal (/.Co Sub)))
                  (not (//check.subsumes? (type_literal (/.Co Sub)) (type_literal (/.Co Super))))))
           (_.coverage [/.Contra]
             (and (//check.subsumes? (type_literal (/.Contra Sub)) (type_literal (/.Contra Super)))
                  (not (//check.subsumes? (type_literal (/.Contra Super)) (type_literal (/.Contra Sub))))))
           (_.coverage [/.In]
             (and (//check.subsumes? (type_literal (/.In Super)) (type_literal (/.In Super)))
                  (//check.subsumes? (type_literal (/.In Sub)) (type_literal (/.In Sub)))
                  (not (//check.subsumes? (type_literal (/.In Sub)) (type_literal (/.In Super))))
                  (not (//check.subsumes? (type_literal (/.In Super)) (type_literal (/.In Sub))))))
           )))