diff options
author | Eduardo Julian | 2019-04-26 18:01:12 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-26 18:01:12 -0400 |
commit | e0b3538721a71f6e8c016b12c8c257b8cebd3981 (patch) | |
tree | 1263740cda4bff9311e58d5bb217e7565060d724 /stdlib/source/spec/compositor/generation/primitive.lux | |
parent | f2c0473640e8029f27797f6ecf21662dddb0685b (diff) |
WIP: Turning compiler tests into a re-usable specification.
Diffstat (limited to 'stdlib/source/spec/compositor/generation/primitive.lux')
-rw-r--r-- | stdlib/source/spec/compositor/generation/primitive.lux | 47 |
1 files changed, 47 insertions, 0 deletions
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 [<evaluation-name> <synthesis> <gen> <test>] + [(do r.monad + [expected <gen>] + (_.test (%name (name-of <synthesis>)) + (|> (run <evaluation-name> (<synthesis> expected)) + (case> (#error.Success actual) + (<test> 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@=] + )) + ))) |