aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/macro/template.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/macro/template.lux63
1 files changed, 63 insertions, 0 deletions
diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux
new file mode 100644
index 000000000..6e90ac1bb
--- /dev/null
+++ b/stdlib/source/test/lux/macro/template.lux
@@ -0,0 +1,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)))))
+ )))
+ ))