aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux
blob: d62fa8ebddc5e5ed36c62de023abf4983b4a8eea (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
39
40
41
42
43
44
45
(.using
 [library
  [lux "*"
   ["_" test (.only Test)]
   [abstract
    [monad (.only do)]
    [\\specification
     ["$[0]" equivalence]]]
   [data
    ["[0]" bit ("[1]#[0]" equivalence)]
    ["[0]" text ("[1]#[0]" equivalence)]]
   [math
    ["[0]" random (.only Random) ("[1]#[0]" monad)]
    [number
     ["f" frac]]]]]
 [\\library
  ["[0]" /]])

(def: .public random
  (Random /.Simple)
  (all random.or
       (random#in [])
       random.bit
       random.nat
       random.int
       random.rev
       (random.only (|>> f.not_a_number? not) random.frac)
       (random.lower_case 5)
       ))

(def: .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Simple])
      (all _.and
           (_.for [/.equivalence]
                  ($equivalence.spec /.equivalence ..random))
           
           (do random.monad
             [left ..random
              right ..random]
             (_.coverage [/.format]
               (bit#= (# /.equivalence = left right)
                      (text#= (/.format left) (/.format right)))))
           )))