aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/version.lux
blob: 6767da8dd246fdf1d5ed45dbdf4b74661d1f51c7 (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
(.using
 [library
  [lux (.except)
   ["_" test (.only Test)]
   ["[0]" static]
   ["[0]" meta]
   [abstract
    [monad (.only do)]]
   [control
    ["[0]" try]
    ["[0]" exception]
    [parser
     ["<[0]>" code]]]
   [data
    ["[0]" text]]
   ["[0]" macro (.only)
    [syntax (.only syntax)]
    ["[0]" code]]
   [math
    ["[0]" random]
    [number
     ["n" nat]]]]]
 [\\library
  ["[0]" /]])

(def failure
  (syntax (_ [it <code>.any])
    (function (_ lux)
      (case (macro.expansion it lux)
        {try.#Failure error}
        {try.#Success [lux (list (code.text error))]}
        
        {try.#Success _}
        {try.#Failure ""}))))

(def .public test
  Test
  (<| (_.covering /._)
      (with_expansions [<current> (/.current)
                        <fake> (static.random code.text (random.lower_case 1))])
      (all _.and
           (_.coverage [/.latest]
             (n.> 0 /.latest))
           (_.coverage [/.current]
             (not (text.empty? (/.current))))
           (_.coverage [/.for]
             (and (/.for <current> true
                         false)
                  (/.for <fake> false
                         true)))
           (_.coverage [/.invalid]
             (and (text.contains? (the exception.#label /.invalid)
                                  (..failure (/.for)))
                  (text.contains? (the exception.#label /.invalid)
                                  (..failure (/.for <fake> false)))))
           )))