aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux
blob: 446a91717ee6f68156fa7a4136446cd838c14896 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(.using
 [library
  [lux "*"
   ["_" test {"+" Test}]
   [abstract
    [monad {"+" do}]
    [\\specification
     ["$[0]" equivalence]]]
   [control
    ["[0]" try ("[1]#[0]" functor)]
    [parser
     ["<[0]>" binary]]]
   [data
    ["[0]" text ("[1]#[0]" equivalence)]
    [format
     ["[0]" binary]]]
   [math
    ["[0]" random {"+" Random} ("[1]#[0]" monad)]]]]
 [\\library
  ["[0]" /]])

(def: random_module_state
  (Random Module_State)
  (all random.or
       (random#in [])
       (random#in [])
       (random#in [])
       ))

(def: .public (random imports)
  (-> Nat (Random /.Descriptor))
  (all random.and
       (random.lower_case 1)
       (random.lower_case 1)
       random.nat
       ..random_module_state
       (random.set text.hash imports (random.lower_case 2))
       ))

(def: .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Descriptor])
      (do random.monad
        [expected (..random 5)])
      (all _.and
           (_.for [/.equivalence]
                  ($equivalence.spec /.equivalence (..random 1)))

           (_.for [/.Module]
                  (_.coverage [/.runtime]
                    (text#= "" /.runtime)))
           (_.coverage [/.writer /.parser]
             (|> expected
                 (binary.result /.writer)
                 (<binary>.result /.parser)
                 (try#each (|>> (# /.equivalence = (has /.#state {.#Cached} expected))))
                 (try.else false)))
           )))