aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/meta/type.lux4
-rw-r--r--stdlib/source/test/lux/meta/type/poly.lux48
2 files changed, 51 insertions, 1 deletions
diff --git a/stdlib/source/test/lux/meta/type.lux b/stdlib/source/test/lux/meta/type.lux
index 3c6872d26..67119dd60 100644
--- a/stdlib/source/test/lux/meta/type.lux
+++ b/stdlib/source/test/lux/meta/type.lux
@@ -41,7 +41,8 @@
["[1][0]" refinement]
["[1][0]" resource]
["[1][0]" unit]
- ["[1][0]" variance]])
+ ["[1][0]" variance]
+ ["[1][0]" poly]])
(def !expect
(template (_ <pattern> <value>)
@@ -570,4 +571,5 @@
/resource.test
/unit.test
/variance.test
+ /poly.test
)))
diff --git a/stdlib/source/test/lux/meta/type/poly.lux b/stdlib/source/test/lux/meta/type/poly.lux
new file mode 100644
index 000000000..e2aa7d03e
--- /dev/null
+++ b/stdlib/source/test/lux/meta/type/poly.lux
@@ -0,0 +1,48 @@
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]]
+ [control
+ ["?" parser]]
+ [data
+ ["[0]" bit (.use "[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random]
+ [number
+ ["[0]" nat (.use "[1]#[0]" equivalence)]]]
+ [meta
+ ["[0]" static]
+ ["[0]" type
+ ["?[1]" \\parser]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" /]])
+
+(with_expansions [<bit> (static.random_bit)
+ <nat> (static.random_nat)]
+ (def constant
+ (/.polytypic constant
+ (`` (all ?.either
+ (,, (with_template [<type> <constant>]
+ [(do ?.monad
+ [_ (?type.sub <type>)]
+ (in (` (is <type>
+ <constant>))))]
+
+ [Bit <bit>]
+ [Nat <nat>]))
+ ))))
+
+ (def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [])
+ (all _.and
+ (_.coverage [/.polytypic]
+ (and (bit#= <bit> (constant Bit))
+ (nat#= <nat> (constant Nat))))
+ )))
+ )