From e0b3538721a71f6e8c016b12c8c257b8cebd3981 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 26 Apr 2019 18:01:12 -0400 Subject: WIP: Turning compiler tests into a re-usable specification. --- .../spec/compositor/generation/primitive.lux | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 stdlib/source/spec/compositor/generation/primitive.lux (limited to 'stdlib/source/spec/compositor/generation/primitive.lux') diff --git a/stdlib/source/spec/compositor/generation/primitive.lux b/stdlib/source/spec/compositor/generation/primitive.lux new file mode 100644 index 000000000..788085836 --- /dev/null +++ b/stdlib/source/spec/compositor/generation/primitive.lux @@ -0,0 +1,47 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)]] + [data + ["." error] + ["." bit ("#@." equivalence)] + [number + ["." frac]] + ["." text ("#@." equivalence) + format]] + [math + ["r" random]] + [tool + [compiler + ["." synthesis]]]] + ["." ///]) + +(def: (f/=' reference subject) + (-> Frac Frac Bit) + (or (f/= reference subject) + (and (frac.not-a-number? reference) + (frac.not-a-number? subject)))) + +(def: #export (spec run) + (-> ///.Runner Test) + (`` ($_ _.and + (~~ (template [ ] + [(do r.monad + [expected ] + (_.test (%name (name-of )) + (|> (run ( expected)) + (case> (#error.Success actual) + ( expected (:assume actual)) + + (#error.Failure error) + false))))] + + ["bit" synthesis.bit r.bit bit@=] + ["i64" synthesis.i64 r.i64 "lux i64 ="] + ["f64" synthesis.f64 r.frac f/='] + ["text" synthesis.text (r.ascii 5) text@=] + )) + ))) -- cgit v1.2.3