aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/artifact.lux
blob: da194124578e1eb59d9010e265fc034ce848d197 (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
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]
     [hash (#+ Hash)]
     [\\specification
      ["$." equivalence]
      ["$." order]
      ["$." hash]]]
    [data
     ["." text ("#\." equivalence)]]
    [math
     ["." random (#+ Random)]]
    [world
     ["." file]
     [net
      ["." uri]]]]]
  ["." / #_
   ["#." extension]
   ["#." snapshot]
   ["#." time]
   ["#." type]
   ["#." versioning]]
  [\\program
   ["." /]])

(def: .public random
  (Random /.Artifact)
  (let [size 4]
    ($_ random.and
        (random.ascii/lower size)
        (random.ascii/lower size)
        (random.ascii/lower size))))

(def: .public test
  Test
  (<| (_.covering /._)
      (do random.monad
        [sample ..random])
      (_.for [/.Group /.Name /.Version
              /.Artifact]
             ($_ _.and
                 (_.for [/.equivalence]
                        ($equivalence.spec /.equivalence ..random))
                 (_.for [/.order]
                        ($order.spec /.order ..random))
                 (_.for [/.hash]
                        ($hash.spec /.hash ..random))

                 (_.cover [/.format /.identity]
                          (and (text.ends_with? (/.identity sample) (/.format sample))
                               (not (text\= (/.identity sample) (/.format sample)))))
                 
                 /extension.test
                 /snapshot.test
                 /time.test
                 /type.test
                 /versioning.test
                 ))))