aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test')
-rw-r--r--stdlib/source/test/lux/tool.lux4
-rw-r--r--stdlib/source/test/lux/tool/compiler/reference.lux95
-rw-r--r--stdlib/source/test/lux/tool/compiler/reference/variable.lux6
3 files changed, 102 insertions, 3 deletions
diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux
index 37e45bcee..ef83286b4 100644
--- a/stdlib/source/test/lux/tool.lux
+++ b/stdlib/source/test/lux/tool.lux
@@ -5,7 +5,7 @@
["[0]" / "_"
[compiler
["[1][0]" arity]
- ["[1][0]" reference/variable]
+ ["[1][0]" reference]
... [language
... [lux
... ["[1][0]" syntax]
@@ -18,7 +18,7 @@
Test
($_ _.and
/arity.test
- /reference/variable.test
+ /reference.test
... /syntax.test
... /analysis.test
... /synthesis.test
diff --git a/stdlib/source/test/lux/tool/compiler/reference.lux b/stdlib/source/test/lux/tool/compiler/reference.lux
new file mode 100644
index 000000000..fd76a5146
--- /dev/null
+++ b/stdlib/source/test/lux/tool/compiler/reference.lux
@@ -0,0 +1,95 @@
+(.using
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]
+ [\\specification
+ ["$[0]" equivalence]
+ ["$[0]" hash]]]
+ [data
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format]]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]]]
+ [meta
+ ["[0]" symbol ("[1]#[0]" equivalence)]]]]
+ [\\library
+ ["[0]" /
+ ["[0]" variable {"+" Register}]]]
+ ["[0]" / "_"
+ ["[1][0]" variable]])
+
+(def: constant
+ (Random /.Constant)
+ ($_ random.and
+ (random.ascii/upper 5)
+ (random.ascii/lower 5)
+ ))
+
+(def: .public random
+ (Random /.Reference)
+ ($_ random.or
+ /variable.random
+ ..constant
+ ))
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Reference /.Constant])
+ (do random.monad
+ [expected_register random.nat
+ expected_constant ..constant])
+ (`` ($_ _.and
+ (_.for [/.equivalence]
+ ($equivalence.spec /.equivalence ..random))
+ (_.for [/.hash]
+ ($hash.spec /.hash ..random))
+
+ (~~ (template [<tag>]
+ [(_.cover [<tag>]
+ (case (<tag> expected_register)
+ (^ (<tag> actual_register))
+ (n.= expected_register actual_register)
+
+ _
+ false))]
+
+ [/.local]
+ [/.foreign]
+ ))
+
+ (_.cover [/.variable /.self]
+ (and (# /.equivalence = (/.self) (/.variable (variable.self)))
+ (case (/.self)
+ (^ (/.self))
+ true
+
+ _
+ false)
+ (case (/.variable (variable.self))
+ (^ (/.self))
+ true
+
+ _
+ false)))
+ (_.cover [/.constant]
+ (case (/.constant expected_constant)
+ (^ (/.constant actual_constant))
+ (symbol#= expected_constant actual_constant)
+
+ _
+ false))
+ (_.cover [/.format]
+ (and (text#= (/.format (/.local expected_register))
+ (variable.format {variable.#Local expected_register}))
+ (text#= (/.format (/.foreign expected_register))
+ (variable.format {variable.#Foreign expected_register}))
+ (text#= (/.format (/.constant expected_constant))
+ (%.symbol expected_constant))))
+
+ /variable.test
+ ))))
diff --git a/stdlib/source/test/lux/tool/compiler/reference/variable.lux b/stdlib/source/test/lux/tool/compiler/reference/variable.lux
index 980a280f0..15d0997e4 100644
--- a/stdlib/source/test/lux/tool/compiler/reference/variable.lux
+++ b/stdlib/source/test/lux/tool/compiler/reference/variable.lux
@@ -32,7 +32,11 @@
($equivalence.spec /.equivalence ..random))
(_.for [/.hash]
($hash.spec /.hash ..random))
- (_.cover [/.self /.self?]
+ (_.cover [/.self]
+ (case (/.self)
+ (^ (/.self)) true
+ _ false))
+ (_.cover [/.self?]
(/.self? (/.self)))
(_.for [/.Register]
(_.cover [/.format]