aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/spec/compositor/generation
diff options
context:
space:
mode:
authorEduardo Julian2019-04-26 21:37:40 -0400
committerEduardo Julian2019-04-26 21:37:40 -0400
commit084e3c400410e954b633a07c98f32ecfa62f1ec8 (patch)
tree724d80a027a8037698068971cd23d00b2042c287 /stdlib/source/spec/compositor/generation
parente0b3538721a71f6e8c016b12c8c257b8cebd3981 (diff)
Ported reference tests.
Diffstat (limited to '')
-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)))