aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/abstract/monad/free.lux2
-rw-r--r--stdlib/source/test/lux/control/function.lux4
-rw-r--r--stdlib/source/test/lux/control/function/trampoline.lux50
-rw-r--r--stdlib/source/test/lux/meta/macro.lux4
-rw-r--r--stdlib/source/test/lux/meta/macro/vocabulary.lux61
5 files changed, 118 insertions, 3 deletions
diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux
index eb67429b2..46fd74651 100644
--- a/stdlib/source/test/lux/abstract/monad/free.lux
+++ b/stdlib/source/test/lux/abstract/monad/free.lux
@@ -29,7 +29,7 @@
{/.#Pure value}
(list value)
- {/.#Effect effect}
+ {/.#Impure effect}
(|> effect
(list#each interpret)
list.together)))
diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux
index a2ac4a355..aad5f2ebf 100644
--- a/stdlib/source/test/lux/control/function.lux
+++ b/stdlib/source/test/lux/control/function.lux
@@ -22,7 +22,8 @@
["[1][0]" inline]
["[1][0]" predicate]
["[1][0]" variadic]
- ["[1][0]" named]])
+ ["[1][0]" named]
+ ["[1][0]" trampoline]])
(def .public test
Test
@@ -71,4 +72,5 @@
/predicate.test
/variadic.test
/named.test
+ /trampoline.test
))))
diff --git a/stdlib/source/test/lux/control/function/trampoline.lux b/stdlib/source/test/lux/control/function/trampoline.lux
new file mode 100644
index 000000000..18d29110c
--- /dev/null
+++ b/stdlib/source/test/lux/control/function/trampoline.lux
@@ -0,0 +1,50 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]
+ [\\specification
+ ["$[0]" functor (.only Injection Comparison)]
+ ["$[0]" monad]]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(def injection
+ (Injection /.Trampoline)
+ (|>> /.return))
+
+(def comparison
+ (Comparison /.Trampoline)
+ (function (_ == left right)
+ (== (/.result left) (/.result right))))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Trampoline])
+ (do [! random.monad]
+ [expected random.nat
+ left random.nat
+ right random.nat])
+ (all _.and
+ (_.for [/.functor]
+ ($functor.spec ..injection ..comparison /.functor))
+ (_.for [/.monad]
+ ($monad.spec ..injection ..comparison /.monad))
+
+ (_.coverage [/.return /.result]
+ (|> (/.return expected)
+ /.result
+ (same? expected)))
+ (_.coverage [/.jump]
+ (with_expansions [<expected> (n.+ left right)]
+ (|> (/.jump (/.return <expected>))
+ /.result
+ (n.= <expected>))))
+ )))
diff --git a/stdlib/source/test/lux/meta/macro.lux b/stdlib/source/test/lux/meta/macro.lux
index d3bc360d4..797c7fac6 100644
--- a/stdlib/source/test/lux/meta/macro.lux
+++ b/stdlib/source/test/lux/meta/macro.lux
@@ -35,7 +35,8 @@
["[1][0]" local]
["[1][0]" syntax]
["[1][0]" template]
- ["[1][0]" pattern]])
+ ["[1][0]" pattern]
+ ["[1][0]" vocabulary]])
(def !expect
(template (_ <pattern> <value>)
@@ -256,4 +257,5 @@
/syntax.test
/template.test
/pattern.test
+ /vocabulary.test
)))
diff --git a/stdlib/source/test/lux/meta/macro/vocabulary.lux b/stdlib/source/test/lux/meta/macro/vocabulary.lux
new file mode 100644
index 000000000..1a04215b3
--- /dev/null
+++ b/stdlib/source/test/lux/meta/macro/vocabulary.lux
@@ -0,0 +1,61 @@
+(.require
+ [library
+ [lux (.except macro)
+ [abstract
+ [monad (.only do)]]
+ [control
+ ["[0]" try]
+ ["[0]" exception]]
+ [data
+ ["[0]" text]]
+ [math
+ [number
+ ["n" nat]]]
+ ["[0]" meta (.only)
+ ["[0]" static]
+ ["[0]" code]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(/.vocabulary
+ [.private Micro]
+ [.private micro]
+ [.private macro]
+ [.private by_name])
+
+(def .public pass_through
+ (.macro (_ inputs lux)
+ {.#Right [lux inputs]}))
+
+(def .public pass_through'
+ (..micro pass_through))
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (all _.and
+ (_.coverage [/.vocabulary]
+ (exec
+ (|> pass_through
+ (is Macro)
+ ..micro
+ (is ..Micro)
+ ..macro
+ (is Macro))
+ (<| static.expansion
+ (do meta.monad
+ [_ (by_name (symbol ..pass_through'))]
+ (in (list (code.bit true)))))))
+ (_.coverage [/.invalid_type]
+ (<| static.expansion
+ (do meta.monad
+ [? (meta.try (by_name (symbol ..pass_through)))]
+ (in (list (code.bit (when ?
+ {try.#Failure it}
+ (text.contains? (the exception.#label /.invalid_type) it)
+
+ {try.#Success _}
+ false)))))))
+ )))