aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/package.lux
blob: c1add80d300e260622153fc30080d79bd727ff3b (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
62
63
64
65
66
67
68
69
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [monad (#+ do)]]
   [control
    ["." try]
    [concurrency
     [promise (#+ Promise)]]]
   [data
    ["." text]
    [collection
     ["." set (#+ Set)]]
    [number
     ["n" nat]]]
   [math
    ["." random (#+ Random)]]
   [world
    ["." file]]]
  [//
   ["@." profile]
   [//
    [lux
     [data
      ["_." binary]]]]]
  {#program
   ["." /
    ["/#" // #_
     ["#" profile]
     ["#." dependency (#+ Dependency)]
     ["#." pom]
     ["#." hash]]]})

(def: #export random
  (Random [//.Profile /.Package])
  (do {! random.monad}
    [content-size (\ ! map (n.% 100) random.nat)
     content (_binary.random content-size)
     [profile pom] (random.one (function (_ profile)
                                 (try.to-maybe
                                  (do try.monad
                                    [pom (//pom.write profile)]
                                    (wrap [profile pom]))))
                               @profile.random)]
    (wrap [profile (/.local pom content)])))

(def: #export test
  Test
  (<| (_.covering /._)
      (_.with-cover [/.Package])
      (do {! random.monad}
        [[profile package] ..random]
        ($_ _.and
            (_.cover [/.local]
                     (and (\ //hash.equivalence =
                             (//hash.sha-1 (get@ #/.library package))
                             (get@ #/.sha-1 package))
                          (\ //hash.equivalence =
                             (//hash.md5 (get@ #/.library package))
                             (get@ #/.md5 package))))
            (_.cover [/.dependencies]
                     (let [expected (get@ #//.dependencies profile)]
                       (case (/.dependencies package)
                         (#try.Success actual)
                         (\ set.equivalence = expected actual)
                         
                         (#try.Failure error)
                         false)))
            ))))