aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/macro/template.lux
blob: 6e90ac1bbd4b405cd420d23eb64c3354b9025c94 (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
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [math
    ["." random (#+ Random)]]
   [abstract
    [monad (#+ do)]]
   [data
    [collection
     ["." list]]
    [number
     ["." nat]]]]
  {1
   ["." /]})

(def: #export test
  Test
  (<| (_.covering /._)
      (do {@ random.monad}
        [left random.nat
         mid random.nat
         right random.nat]
        (with-expansions [<module> (as-is [-8.9 +6.7 .5 -4 +3 2 #1 #0 #c b "a"])
                          <module>' "-8.9+6.7.5-4+32#1#0cba"
                          <short> (as-is ["a" b #c #0 #1 2 +3 -4 .5 +6.7 -8.9])
                          <short>' "abc#0#12+3-4.5+6.7-8.9"]
          ($_ _.and
              (_.cover [/.splice]
                       (:: (list.equivalence nat.equivalence) =
                           (list left mid right)
                           (`` (list (~~ (/.splice [left mid right]))))))
              (_.cover [/.count]
                       (case (/.count [left mid right])
                         3 true
                         _ false))
              (_.cover [/.text]
                       (case (/.text <short>)
                         <short>' true
                         _ false))
              (_.cover [/.identifier]
                       (and (case (`` (name-of (~~ (/.identifier <short>))))
                              ["" <short>'] true
                              _ false)
                            (case (`` (name-of (~~ (/.identifier <module> <short>))))
                              [<module>' <short>'] true
                              _ false)
                            ))
              (_.cover [/.tag]
                       (and (case (`` (name-of (~~ (/.tag <short>))))
                              ["" <short>'] true
                              _ false)
                            (case (`` (name-of (~~ (/.tag <module> <short>))))
                              [<module>' <short>'] true
                              _ false)
                            ))
              (_.cover [/.with-locals]
                       (/.with-locals [var0 var1]
                         (let [var0 left
                               var1 right]
                           (and (nat.= left var0)
                                (nat.= right var1)))))
              )))
      ))