aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/package.lux
blob: b85f6ce4a2104e322b5835cb39a25710bb74ac45 (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
(.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 test
  Test
  (<| (_.covering /._)
      (_.with-cover [/.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)]
        ($_ _.and
            (_.cover [/.local]
                     (let [package (/.local pom content)]
                       (and (:: //hash.equivalence =
                                (//hash.sha-1 content)
                                (get@ #/.sha-1 package))
                            (:: //hash.equivalence =
                                (//hash.md5 content)
                                (get@ #/.md5 package)))))
            (_.cover [/.dependencies]
                     (let [expected (get@ #//.dependencies profile)]
                       (case (/.dependencies (/.local pom content))
                         (#try.Success actual)
                         (:: set.equivalence = expected actual)
                         
                         (#try.Failure error)
                         false)))
            ))))