From 0abd5bd3c0e38e352e9ba38268e04e1c858ab01e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 15 Jul 2021 00:45:15 -0400 Subject: Re-named "spec" hierarchy to "specification". --- .../compositor/generation/primitive.lux | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 stdlib/source/specification/compositor/generation/primitive.lux (limited to 'stdlib/source/specification/compositor/generation/primitive.lux') diff --git a/stdlib/source/specification/compositor/generation/primitive.lux b/stdlib/source/specification/compositor/generation/primitive.lux new file mode 100644 index 000000000..3b6dd657b --- /dev/null +++ b/stdlib/source/specification/compositor/generation/primitive.lux @@ -0,0 +1,48 @@ +(.module: + [lux #* + ["_" test (#+ Test)] + [abstract + [monad (#+ do)]] + [control + [pipe (#+ case>)] + ["." try]] + [data + ["." bit ("#\." equivalence)] + [number + ["f" frac]] + ["." text ("#\." equivalence) + ["%" format (#+ format)]]] + [math + ["r" random]] + [tool + [compiler + ["." synthesis]]]] + [/// + [common (#+ Runner)]]) + +(def: (f/=' reference subject) + (-> Frac Frac Bit) + (or (f.= reference subject) + (and (f.not-a-number? reference) + (f.not-a-number? subject)))) + +(def: #export (spec run) + (-> Runner Test) + (`` ($_ _.and + (~~ (template [ ] + [(do r.monad + [expected ] + (_.test (%.name (name-of )) + (|> (run ( expected)) + (case> (#try.Success actual) + ( expected (:assume actual)) + + (#try.Failure _) + 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