diff options
author | Eduardo Julian | 2023-01-05 02:33:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2023-01-05 02:33:52 -0400 |
commit | ab1829d77c7d12af344af68d6c50d391f1126640 (patch) | |
tree | eb7a228fbe22a7631272e14b5ac6743c64dafaee /stdlib/source/test/lux/world | |
parent | 3ca054b6b992e2233d763aabc5c938ee10d116a4 (diff) |
Compilation of simple literals in C++.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/world/console.lux | 56 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/environment.lux | 27 | ||||
-rw-r--r-- | stdlib/source/test/lux/world/finance/money.lux | 8 |
3 files changed, 72 insertions, 19 deletions
diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index 7d933d926..4e26b107c 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -4,20 +4,62 @@ [abstract [monad (.only do)]] [control - ["[0]" io] + ["[0]" io (.only IO)] ["[0]" try (.only Try)] - ["[0]" exception]] + ["[0]" exception] + [concurrency + ["[0]" async (.only Async)]]] [data ["[0]" text (.use "[1]#[0]" equivalence) ["%" \\format (.only format)]]] [math ["[0]" random]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)] + ["[0]" unit]]]] [\\library - ["[0]" /]] - [\\specification - ["$[0]" /]]) + ["[0]" /]]) + +(def .public (spec console) + (-> (IO (/.Console Async)) + Test) + (do random.monad + [message (random.alphabetic 10)] + (in (do async.monad + [console (async.future console) + ?write (of console write (format message text.new_line)) + ?read (of console read []) + ?read_line (of console read_line []) + ?close/good (of console close []) + ?close/bad (of console close []) + + .let [can_write! + (when ?write + {try.#Success _} + true + + _ + false) + + can_read! + (when [?read ?read_line] + [{try.#Success _} {try.#Success _}] + true + + _ + false) + + can_close! + (when [?close/good ?close/bad] + [{try.#Success _} {try.#Failure _}] + true + + _ + false)]] + (unit.coverage [/.Console] + (and can_write! + can_read! + can_close!)))))) (exception.def dead) @@ -54,7 +96,7 @@ (<| (_.covering /._) (all _.and (_.for [/.async /.mock /.Mock] - ($/.spec (io.io (/.async (/.mock ..mock [false ""]))))) + (..spec (io.io (/.async (/.mock ..mock [false ""]))))) (do random.monad [expected (random.alphabetic 10) .let [console (/.mock ..mock [false ""])]] diff --git a/stdlib/source/test/lux/world/environment.lux b/stdlib/source/test/lux/world/environment.lux index 8c2484e7b..c6b2e95e2 100644 --- a/stdlib/source/test/lux/world/environment.lux +++ b/stdlib/source/test/lux/world/environment.lux @@ -9,7 +9,9 @@ ["[0]" io] ["[0]" maybe (.use "[1]#[0]" functor)] ["[0]" try] - ["[0]" exception]] + ["[0]" exception] + [concurrency + ["[0]" async (.only Async)]]] [data ["[0]" text (.use "[1]#[0]" equivalence)] [collection @@ -20,14 +22,27 @@ [number ["n" nat]]] [test - ["_" property (.only Test)]]]] + ["_" property (.only Test)] + ["[0]" unit]]]] ["[0]" \\parser (.only Environment)] [\\library ["[0]" / (.only) [// - [file (.only Path)]]]] - [\\specification - ["$[0]" /]]) + [file (.only Path)]]]]) + +(def .public (spec subject) + (-> (/.Environment Async) + Test) + (do random.monad + [exit random.int] + (in (do [! async.monad] + [environment (/.environment ! subject)] + (unit.coverage [/.Environment] + (and (not (dictionary.empty? environment)) + (list.every? (|>> text.empty? not) + (dictionary.keys environment)) + (not (text.empty? (of subject home))) + (not (text.empty? (of subject directory))))))))) (def \\parser Test @@ -84,7 +99,7 @@ unknown (random.alphabetic 1)] (all _.and (_.for [/.mock /.async] - ($/.spec (/.async (/.mock environment home directory)))) + (..spec (/.async (/.mock environment home directory)))) (_.coverage [/.environment] (let [it (/.mock environment home directory)] (io.run! diff --git a/stdlib/source/test/lux/world/finance/money.lux b/stdlib/source/test/lux/world/finance/money.lux index 872414dbf..cc798afdd 100644 --- a/stdlib/source/test/lux/world/finance/money.lux +++ b/stdlib/source/test/lux/world/finance/money.lux @@ -90,12 +90,8 @@ (bit#= (/.<= expected_parameter expected_subject) (/.>= expected_subject expected_parameter))) )) - (_.coverage [/.units /.sub_units] - (let [expected (/.money currency.usd expected_amount) - actual (/.money currency.usd (n.+ (/.units expected) - (/.sub_units expected)))] - (/.= expected actual))) - (_.coverage [/.of_units /.of_sub_units] + (_.coverage [/.units /.sub_units + /.of_units /.of_sub_units] (let [expected (/.money currency.usd expected_amount) actual (/.+ (/.of_units currency.usd (/.units expected)) (/.of_sub_units currency.usd (/.sub_units expected)))] |