aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/compiler/meta/cache/dependency/module.lux
blob: 8c2633c95774db906a7faca482bb31cf9460b64a (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
60
61
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [data
    ["[0]" text]
    [collection
     ["[0]" dictionary]
     ["[0]" set (.use "[1]#[0]" equivalence)]]]
   [math
    ["[0]" random (.only Random)]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(def .public test
  Test
  (<| (_.covering /._)
      (do [! random.monad]
        [module/0 (random.lower_cased 1)
         module/1 (random.lower_cased 2)
         module/2 (random.lower_cased 3)])
      (all _.and
           (<| (_.for [/.Ancestry])
               (all _.and
                    (_.coverage [/.fresh]
                      (set.empty? /.fresh))
                    ))
           (<| (_.for [/.Graph])
               (all _.and
                    (_.coverage [/.empty]
                      (dictionary.empty? /.empty))
                    (_.coverage [/.modules]
                      (let [expected (set.of_list text.hash (list module/0 module/1 module/2))
                            actual (|> /.empty
                                       (dictionary.has module/0 /.fresh)
                                       (dictionary.has module/1 /.fresh)
                                       (dictionary.has module/2 /.fresh)
                                       /.modules
                                       (set.of_list text.hash))]
                        (set#= expected actual)))
                    ))
           (<| (_.for [/.Dependency])
               (all _.and
                    (_.coverage [/.graph]
                      (let [expected (set.of_list text.hash (list module/0 module/1 module/2))
                            actual (|> (/.graph (list [module/0 /.fresh]
                                                      [module/1 /.fresh]
                                                      [module/2 /.fresh]))
                                       /.modules
                                       (set.of_list text.hash))]
                        (set#= expected actual)))
                    ))
           (<| (_.for [/.Order])
               (all _.and
                    (_.coverage [/.load_order]
                      false)
                    ))
           )))