diff options
Diffstat (limited to 'stdlib/source/test')
-rw-r--r-- | stdlib/source/test/lux/target/python.lux | 50 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool.lux | 4 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/meta/cache.lux | 44 | ||||
-rw-r--r-- | stdlib/source/test/lux/tool/compiler/meta/context.lux | 13 |
4 files changed, 102 insertions, 9 deletions
diff --git a/stdlib/source/test/lux/target/python.lux b/stdlib/source/test/lux/target/python.lux index 3908f9d3c..bb601a007 100644 --- a/stdlib/source/test/lux/target/python.lux +++ b/stdlib/source/test/lux/target/python.lux @@ -432,19 +432,55 @@ (def: test|statement Test (do [! random.monad] - [prefix (# ! each (|>> %.nat (text.enclosed ["def_" "_"])) random.nat) + [$def (# ! each (|>> %.nat (format "def_") /.var) random.nat) $input/0 (# ! each (|>> %.nat (format "input_") /.var) random.nat) expected/0 random.safe_frac - .let [def (: (-> Nat /.SVar) - (|>> %.nat (format prefix) /.var))]] + test random.bit + then random.safe_frac + else random.safe_frac + .let [expected/? (if test then else)]] ($_ _.and - (_.cover [/.def] + (_.cover [/.def /.return] + (|> (..statement + (function (_ $output) + ($_ /.then + (/.def $def (list $input/0) + (/.return $input/0)) + (/.set (list $output) (/.apply/* $def (list (/.float expected/0))))))) + (:as Frac) + (f.= expected/0))) + (_.cover [/.if] + (|> (..statement + (function (_ $output) + ($_ /.then + (/.def $def (list) + (/.if (/.bool test) + (/.return (/.float then)) + (/.return (/.float else)))) + (/.set (list $output) (/.apply/* $def (list)))))) + (:as Frac) + (f.= expected/?))) + (_.cover [/.when /.then] + (|> (..statement + (function (_ $output) + ($_ /.then + (/.def $def (list) + ($_ /.then + (/.when (/.bool test) + (/.return (/.float then))) + (/.return (/.float else)))) + (/.set (list $output) (/.apply/* $def (list)))))) + (:as Frac) + (f.= expected/?))) + (_.cover [/.statement] (|> (..statement (function (_ $output) ($_ /.then - (/.def (def 0) (list $input/0) (/.return $input/0)) - (/.set (list $output) - (/.apply/* (def 0) (list (/.float expected/0))))))) + (/.def $def (list) + ($_ /.then + (/.statement (/.+ (/.float expected/0) (/.float expected/0))) + (/.return (/.float expected/0)))) + (/.set (list $output) (/.apply/* $def (list)))))) (:as Frac) (f.= expected/0))) ))) diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 22267936f..ed089e095 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -27,7 +27,8 @@ ["[1]/[0]" cli] ["[1]/[0]" export] ["[1]/[0]" import] - ["[1]/[0]" context]] + ["[1]/[0]" context] + ["[1]/[0]" cache]] ]]) (def: .public test @@ -43,6 +44,7 @@ /meta/export.test /meta/import.test /meta/context.test + /meta/cache.test /phase/extension.test /phase/analysis/simple.test /phase/analysis/complex.test diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache.lux b/stdlib/source/test/lux/tool/compiler/meta/cache.lux new file mode 100644 index 000000000..9ffcd4ada --- /dev/null +++ b/stdlib/source/test/lux/tool/compiler/meta/cache.lux @@ -0,0 +1,44 @@ +(.using + [library + [lux "*" + ["_" test {"+" Test}] + [abstract + [monad {"+" do}]] + [control + ["[0]" try] + [concurrency + ["[0]" async]]] + [math + ["[0]" random]] + [world + ["[0]" file]]]] + [\\library + ["[0]" /]] + ["$[0]" // "_" + ["[1][0]" context]]) + +(def: .public test + Test + (<| (_.covering /._) + (do [! random.monad] + [.let [/ "/" + fs (file.mock /)] + context $//context.random] + ($_ _.and + (in (do async.monad + [pre/0 (# fs directory? (/.path fs context)) + pre/1 (/.enabled? fs context) + outcome (/.enable! fs context) + post/0 (# fs directory? (/.path fs context)) + post/1 (/.enabled? fs context)] + (_.cover' [/.path /.enabled? /.enable!] + (and (not pre/0) + (not pre/1) + + (case outcome + {try.#Success _} true + {try.#Failure _} false) + + post/0 + post/1)))) + )))) diff --git a/stdlib/source/test/lux/tool/compiler/meta/context.lux b/stdlib/source/test/lux/tool/compiler/meta/context.lux index 382bd12d6..1d9d5b67d 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/context.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/context.lux @@ -10,12 +10,23 @@ ["[0]" set] ["[0]" list ("[1]#[0]" functor)]]] [math - ["[0]" random] + ["[0]" random {"+" Random}] [number ["n" nat]]]]] [\\library ["[0]" /]]) +(def: .public random + (Random /.Context) + (do [! random.monad] + [context ($_ random.either + (in /.js) + (in /.jvm) + (in /.lua) + (in /.python) + (in /.ruby))] + (# ! each context (random.ascii/lower 1)))) + (def: .public test Test (<| (_.covering /._) |