diff options
author | Eduardo Julian | 2019-02-24 21:50:10 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-24 21:50:10 -0400 |
commit | 54b6067f611ecb55a4aff7e0503285aa49db0365 (patch) | |
tree | f0ff63f364d884f2b22942d5607d09760bfe8f20 /stdlib/source/test | |
parent | 2ae7dc30bf91d709a6038871e9c967dafb15cf49 (diff) |
Got rid of the Task type (it just provided the same functionality as (error.with promise.monad)).
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/actor.lux | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index dba286b22..90c88744c 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -6,8 +6,7 @@ ["M" monad (#+ do Monad)] ["ex" exception] [concurrency - ["." promise ("#/." monad)] - ["T" task]]] + ["." promise ("#/." monad)]]] [data ["." error] [text @@ -21,7 +20,7 @@ Nat ((handle message state self) - (do T.monad + (do (error.with promise.monad) [#let [_ (log! "BEFORE")] output (message state self) #let [_ (log! "AFTER")]] @@ -35,47 +34,49 @@ (message: #export Counter (count! {increment Nat} state self Nat) (let [state' (n/+ increment state)] - (T.return [state' state']))) + (promise/wrap (#error.Success [state' state'])))) (def: #export test Test - (<| (_.context (%name (name-of /.Actor))) - ($_ _.and - (_.test "Can check if an actor is alive." - (io.run (do io.monad - [counter (new@Counter 0)] - (wrap (/.alive? counter))))) + (do r.monad + [_ (wrap [])] + (<| (_.context (%name (name-of /.Actor))) + ($_ _.and + (_.test "Can check if an actor is alive." + (io.run (do io.monad + [counter (new@Counter 0)] + (wrap (/.alive? counter))))) - (_.test "Can poison actors." - (io.run (do io.monad - [counter (new@Counter 0) - poisoned? (/.poison counter)] - (wrap (and poisoned? - (not (/.alive? counter))))))) - - (_.test "Cannot poison an already dead actor." - (io.run (do io.monad - [counter (new@Counter 0) - first-time (/.poison counter) - second-time (/.poison counter)] - (wrap (and first-time - (not second-time)))))) + (_.test "Can poison actors." + (io.run (do io.monad + [counter (new@Counter 0) + poisoned? (/.poison counter)] + (wrap (and poisoned? + (not (/.alive? counter))))))) + + (_.test "Cannot poison an already dead actor." + (io.run (do io.monad + [counter (new@Counter 0) + first-time (/.poison counter) + second-time (/.poison counter)] + (wrap (and first-time + (not second-time)))))) - (:: r.monad wrap - (do promise.monad - [result (do T.monad - [#let [counter (io.run (new@Counter 0))] - output-1 (count! 1 counter) - output-2 (count! 1 counter) - output-3 (count! 1 counter)] - (wrap (and (n/= 1 output-1) - (n/= 2 output-2) - (n/= 3 output-3))))] - (_.assert "Can send messages to actors." - (case result - (#error.Success outcome) - outcome + (:: r.monad wrap + (do promise.monad + [result (do (error.with promise.monad) + [#let [counter (io.run (new@Counter 0))] + output-1 (count! 1 counter) + output-2 (count! 1 counter) + output-3 (count! 1 counter)] + (wrap (and (n/= 1 output-1) + (n/= 2 output-2) + (n/= 3 output-3))))] + (_.assert "Can send messages to actors." + (case result + (#error.Success outcome) + outcome - (#error.Failure error) - #0)))) - ))) + (#error.Failure error) + #0)))) + )))) |