aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/profile.lux
blob: 591ad4d5dd11f64b65e77a54bd5d6078e2fb53eb (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
(.require
 [library
  [lux (.except symbol)
   [abstract
    [monad (.only do)]
    [hash (.only Hash)]
    [\\specification
     ["$[0]" equivalence]
     ["$[0]" monoid]]]
   [control
    ["[0]" try]]
   [data
    ["[0]" text (.use "[1]#[0]" equivalence)]
    [collection
     ["[0]" set (.only Set)]
     ["[0]" dictionary (.only Dictionary)]]]
   [math
    ["[0]" random (.only Random) (.use "[1]#[0]" monad)]
    [number
     ["n" nat]]]
   [meta
    [compiler
     [meta
      [cli
       ["[0]" compiler (.only)
        ["$[1]" \\test]]]]]]
   [program
    ["cli" \\parser]]
   [test
    ["_" property (.only Test)]]]]
 [//
  ["@[0]" artifact]
  ["@[0]" dependency]]
 [\\program
  ["[0]" / (.only)
   ["/[1]" //
    ["[1][0]" runtime]
    ["[1][0]" dependency (.only Dependency)]
    ["[1][0]" format]
    [repository
     [remote (.only Address)]]]]])

(def distribution
  (Random /.Distribution)
  (random.or (random#in [])
             (random#in [])))

(def license
  (Random /.License)
  (all random.and
       (random.alphabetic 1)
       (random.alphabetic 1)
       ..distribution))

(def scm
  (Random /.SCM)
  (random.alphabetic 1))

(def organization
  (Random /.Organization)
  (all random.and
       (random.alphabetic 1)
       (random.alphabetic 1)))

(def email
  (Random /.Email)
  (random.alphabetic 1))

(def developer
  (Random /.Developer)
  (all random.and
       (random.alphabetic 1)
       (random.alphabetic 1)
       (random.maybe organization)))

(def contributor
  (Random /.Contributor)
  ..developer)

(def (list_of random)
  (All (_ a) (-> (Random a) (Random (List a))))
  (do [! random.monad]
    [size (of ! each (n.% 5) random.nat)]
    (random.list size random)))

(def (set_of hash random)
  (All (_ a) (-> (Hash a) (Random a) (Random (Set a))))
  (of random.functor each
      (set.of_list hash)
      (..list_of random)))

(def (dictionary_of key_hash key_random value_random)
  (All (_ k v) (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v))))
  (of random.functor each
      (dictionary.of_list key_hash)
      (..list_of (random.and key_random value_random))))

(def info
  (Random /.Info)
  (all random.and
       (random.maybe (random.alphabetic 2))
       (random.maybe ..scm)
       (random.maybe (random.alphabetic 3))
       (..list_of ..license)
       (random.maybe ..organization)
       (..list_of ..developer)
       (..list_of ..contributor)
       ))

(def name
  (Random /.Name)
  (random.alphabetic 1))

(def repository
  (Random Address)
  (random.alphabetic 1))

(def source
  (Random /.Source)
  (random.alphabetic 1))

(def target
  (Random /.Target)
  (random.alphabetic 1))

(def (symbol module_size short_size)
  (-> Nat Nat (Random Symbol))
  (random.and (random.alphabetic module_size)
              (random.alphabetic short_size)))

(def .public random
  (Random /.Profile)
  (all random.and
       (..list_of ..name)
       (random.maybe @artifact.random)
       (random.maybe ..info)
       (..set_of text.hash ..repository)
       (..set_of //dependency.hash @dependency.random)
       @dependency.random
       (..list_of $compiler.random)
       (..set_of text.hash ..source)
       ..target
       (random.maybe (symbol 1 2))
       (random.maybe (symbol 3 4))
       (..dictionary_of text.hash (random.alphabetic 5) ..repository)
       (..list_of (random.and (random.alphabetic 6)
                              (random.alphabetic 7)))
       (random#in //runtime.default_java)
       (random#in //runtime.default_js)
       (random#in //runtime.default_python)
       (random#in //runtime.default_lua)
       (random#in //runtime.default_ruby)
       ))

(def .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Distribution /.License /.SCM /.Organization
              /.Email /.Developer /.Contributor /.Info
              /.Source /.Target /.Name /.Profile]
             (`` (all _.and
                      (_.for [/.equivalence]
                             ($equivalence.spec /.equivalence ..random))
                      (_.for [/.monoid]
                             ($monoid.spec /.equivalence /.monoid ..random))

                      (_.coverage [/.default]
                        (text#= "" /.default))
                      (_.coverage [/.default_lux]
                        (|> (of /.monoid identity)
                            (the /.#lux)
                            (same? /.default_lux)))
                      (_.coverage [/.default_target]
                        (|> (of /.monoid identity)
                            (the /.#target)
                            (same? /.default_target)))
                      )))))