aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/bit.lux
blob: 48643c29b8f33c6663708f351bc3cd97938d450a (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
36
37
38
(.module:
  [lux #*
   ["_" test (#+ Test)]
   ["." function]
   [control
    [monad (#+ do)]
    {[0 #test]
     [/
      ["." equivalence]
      ["." codec]]}]
   data/text/format
   [math
    ["r" random]]]
  {1
   ["." /]})

(def: #export test
  Test
  (<| (_.context (%name (name-of .Bit)))
      (do r.monad
        [value r.bit]
        ($_ _.and
            (_.test "A value cannot be true and false at the same time."
                    (not (and value (not value))))
            (_.test "A value must be either true or false at any time."
                    (or value (not value)))
            (_.test "Can create the complement of a predicate."
                    (and (not (:: /.equivalence = value ((/.complement function.identity) value)))
                         (:: /.equivalence = value ((/.complement not) value))))
            (equivalence.test /.equivalence r.bit)
            (codec.test /.codec /.equivalence r.bit)
            (_.test "Or/disjunction monoid."
                    (and (not (:: /.or-monoid identity))
                         (:: /.or-monoid compose value (not value))))
            (_.test "And/conjunction monoid."
                    (and (:: /.and-monoid identity)
                         (not (:: /.and-monoid compose value (not value)))))
            ))))