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

(def .public random
  (Random /.Runtime)
  (all 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.alphabetic 5)
         runtime ..random]
        (`` (all _.and
                 (_.for [/.equivalence]
                        ($equivalence.spec /.equivalence ..random))
                 
                 (~~ (with_template [<command>]
                       [(_.coverage [/.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]
                       ))
                 (_.coverage [/.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)))))
                 )))))