aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/tool/compiler/meta/cli.lux
blob: cc19519501ea72cb586671ef4c9d050328e4734f (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
(.using
 [library
  [lux (.except)
   ["_" test (.only Test)]
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" pipe]
    ["[0]" try (.open: "[1]#[0]" functor)]
    ["<>" parser (.only)
     ["<[0]>" cli]]]
   [data
    ["[0]" product]
    ["[0]" text]
    [collection
     ["[0]" list (.open: "[1]#[0]" monoid monad)]]]
   [math
    ["[0]" random (.only Random)]
    [number
     ["n" nat]]]
   [meta
    ["[0]" configuration (.open: "[1]#[0]" equivalence)
     ["$[1]" \\test]]]]]
 [\\library
  ["[0]" / (.only)
   ["[1][0]" compiler (.only Compiler)]]]
 ["$[0]" /
  ["[1][0]" compiler]])

(def: .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Service /.service])
      (let [(open "list#[0]") (list.equivalence text.equivalence)])
      (do [! random.monad]
        [amount (at ! each (|>> (n.% 5) ++) random.nat)
         sources (random.list amount (random.lower_case 1))
         host_dependencies (random.list amount (random.lower_case 2))
         libraries (random.list amount (random.lower_case 3))
         target (random.lower_case 4)
         module (random.lower_case 5)
         compilers (random.list amount $/compiler.random)
         configuration ($configuration.random 5)
         .let [compilation' (all list#composite
                                 (list#conjoint (list#each (|>> (list "--host_dependency")) host_dependencies))
                                 (list#conjoint (list#each (|>> (list "--library")) libraries))
                                 (list#conjoint (list#each (|>> /compiler.format (list "--compiler")) compilers))
                                 (list#conjoint (list#each (|>> (list "--source")) sources))
                                 (list "--target" target
                                       "--module" module
                                       "--configuration" (configuration.format configuration)))
               export (all list#composite
                           (list#conjoint (list#each (|>> (list "--source")) sources))
                           (list "--target" target))]]
        (all _.and
             (_.for [/.Compilation]
                    (`` (all _.and
                             (~~ (template [<type> <slot> <?>]
                                   [(_.coverage [<type>]
                                      (|> (partial_list "build" compilation')
                                          (<cli>.result /.service)
                                          (try#each (|>> (pipe.case
                                                           {/.#Compilation it}
                                                           (|> it
                                                               (the <slot>)
                                                               <?>)
                                                           
                                                           _
                                                           false)))
                                          (try.else false)))]

                                   [/.Host_Dependency /.#host_dependencies (list#= host_dependencies)]
                                   [/.Library /.#libraries (list#= libraries)]
                                   [/compiler.Compiler /.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
                                   [/.Source /.#sources (list#= sources)]
                                   [/.Target /.#target (same? target)]
                                   [/.Module /.#module (same? module)]
                                   [configuration.Configuration /.#configuration (configuration#= configuration)]
                                   ))
                             )))
             (_.coverage [/.Interpretation]
               (`` (and (~~ (template [<slot> <?>]
                              [(|> (partial_list "repl" compilation')
                                   (<cli>.result /.service)
                                   (try#each (|>> (pipe.case
                                                    {/.#Interpretation it}
                                                    (|> it
                                                        (the <slot>)
                                                        <?>)
                                                    
                                                    _
                                                    false)))
                                   (try.else false))]

                              [/.#host_dependencies (list#= host_dependencies)]
                              [/.#libraries (list#= libraries)]
                              [/.#compilers (at (list.equivalence /compiler.equivalence) = compilers)]
                              [/.#sources (list#= sources)]
                              [/.#target (same? target)]
                              [/.#module (same? module)]
                              [/.#configuration (configuration#= configuration)]
                              )))))
             (_.coverage [/.Export]
               (`` (and (~~ (template [<side> <?>]
                              [(|> (partial_list "export" export)
                                   (<cli>.result /.service)
                                   (try#each (|>> (pipe.case
                                                    {/.#Export it}
                                                    (|> it
                                                        <side>
                                                        <?>)
                                                    
                                                    _
                                                    false)))
                                   (try.else false))]

                              [product.left (list#= sources)]
                              [product.right (same? target)]
                              )))))
             (_.coverage [/.target]
               (`` (and (~~ (template [<it>]
                              [(same? target (/.target <it>))]

                              [{/.#Compilation [/.#host_dependencies host_dependencies
                                                /.#libraries libraries
                                                /.#compilers compilers
                                                /.#sources sources
                                                /.#target target
                                                /.#module module
                                                /.#configuration configuration]}]
                              [{/.#Interpretation [/.#host_dependencies host_dependencies
                                                   /.#libraries libraries
                                                   /.#compilers compilers
                                                   /.#sources sources
                                                   /.#target target
                                                   /.#module module
                                                   /.#configuration configuration]}]
                              [{/.#Export [sources target]}]
                              )))))

             $/compiler.test
             ))))