aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/aedifex/runtime.lux
blob: 99c1bd92d24fe961ff781137a46fa2a4f993580f (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
(.using
 [library
  [lux "*"
   ["_" test {"+" Test}]
   [abstract
    [monad {"+" do}]
    [\\specification
     ["$[0]" equivalence]]]
   [control
    ["[0]" maybe ("[1]#[0]" functor)]]
   [data
    ["[0]" text ("[1]#[0]" equivalence)]
    [collection
     ["[0]" list ("[1]#[0]" functor)]
     ["[0]" set]]]
   [math
    ["[0]" random {"+" Random} ("[1]#[0]" monad)]
    [number
     ["n" nat]]]]]
 [\\program
  ["[0]" /]])

(def: .public random
  (Random /.Runtime)
  ($_ random.either
      (random#in /.default_java)
      (random#in /.default_js)
      (random#in /.default_python)
      (random#in /.default_lua)
      (random#in /.default_ruby)
      ))

(def: .public test
  Test
  (<| (_.covering /._)
      (_.for [/.Runtime])
      (do random.monad
        [path (random.ascii/alpha 5)
         runtime ..random]
        (`` ($_ _.and
                (_.for [/.equivalence]
                       ($equivalence.spec /.equivalence ..random))
                
                (~~ (template [<command>]
                      [(_.cover [/.default_java /.default_js /.default_python /.default_lua /.default_ruby]
                                (let [listing (|> (list /.default_java /.default_js /.default_python /.default_lua /.default_ruby)
                                                  (list#each (the /.#program)))
                                      unique (set.of_list text.hash listing)]
                                  (n.= (list.size listing)
                                       (set.size unique))))]

                      [/.default_java]
                      [/.default_js]
                      [/.default_python]
                      [/.default_lua]
                      [/.default_ruby]
                      ))
                (_.cover [/.for]
                         (let [runtime' (/.for runtime path)]
                           (and (text#= (the /.#program runtime)
                                        (the /.#program runtime'))
                                (|> runtime'
                                    (the /.#parameters)
                                    list.last
                                    (maybe#each (text#= path))
                                    (maybe.else false)))))
                )))))