aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/compositor/generation
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/spec/compositor/generation')
-rw-r--r--stdlib/source/spec/compositor/generation/reference.lux56
1 files changed, 56 insertions, 0 deletions
diff --git a/stdlib/source/spec/compositor/generation/reference.lux b/stdlib/source/spec/compositor/generation/reference.lux
new file mode 100644
index 000000000..35de4e8ef
--- /dev/null
+++ b/stdlib/source/spec/compositor/generation/reference.lux
@@ -0,0 +1,56 @@
+(.module:
+ [lux #*
+ ["_" test (#+ Test)]
+ [abstract
+ [monad (#+ do)]]
+ [control
+ [pipe (#+ case>)]]
+ [data
+ ["." error]]
+ [tool
+ [compiler
+ ["." reference]
+ ["." synthesis]]]
+ [math
+ ["r" random (#+ Random)]]]
+ ["." ///])
+
+(def: name
+ (Random Name)
+ (let [name-part (r.ascii/upper-alpha 5)]
+ [(r.and name-part name-part)]))
+
+(def: (definition define)
+ (-> ///.Definer Test)
+ (do r.monad
+ [name ..name
+ expected r.safe-frac]
+ (_.test "Definitions."
+ (|> (define name (synthesis.f64 expected))
+ (case> (#error.Success actual)
+ (f/= expected (:coerce Frac actual))
+
+ (#error.Failure error)
+ false)))))
+
+(def: (variable run)
+ (-> ///.Runner Test)
+ (do r.monad
+ [register (|> r.nat (:: @ map (n/% 100)))
+ expected r.safe-frac]
+ (_.test "Local variables."
+ (|> (synthesis.branch/let [(synthesis.f64 expected)
+ register
+ (synthesis.variable/local register)])
+ (run "variable")
+ (case> (#error.Success actual)
+ (f/= expected (:coerce Frac actual))
+
+ (#error.Failure error)
+ false)))))
+
+(def: #export (spec runner definer)
+ (-> ///.Runner ///.Definer Test)
+ ($_ _.and
+ (..definition definer)
+ (..variable runner)))