aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/variance.lux
blob: 1914fe8072eeee3feccf9a09e47efde65ddded4a (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
(.using
 [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 (/.Co Super)) (type (/.Co Sub)))
                  (not (//check.subsumes? (type (/.Co Sub)) (type (/.Co Super))))))
           (_.coverage [/.Contra]
             (and (//check.subsumes? (type (/.Contra Sub)) (type (/.Contra Super)))
                  (not (//check.subsumes? (type (/.Contra Super)) (type (/.Contra Sub))))))
           (_.coverage [/.In]
             (and (//check.subsumes? (type (/.In Super)) (type (/.In Super)))
                  (//check.subsumes? (type (/.In Sub)) (type (/.In Sub)))
                  (not (//check.subsumes? (type (/.In Sub)) (type (/.In Super))))
                  (not (//check.subsumes? (type (/.In Super)) (type (/.In Sub))))))
           )))