aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux/concurrency/session.lux65
1 files changed, 38 insertions, 27 deletions
diff --git a/stdlib/test/test/lux/concurrency/session.lux b/stdlib/test/test/lux/concurrency/session.lux
index ea27bf4b9..192421f02 100644
--- a/stdlib/test/test/lux/concurrency/session.lux
+++ b/stdlib/test/test/lux/concurrency/session.lux
@@ -86,6 +86,8 @@
(<| $.send $.receive recur)
$.end))))
+(def: negate (i/* -1))
+
(context: "Complex session."
(do @
[#let [[$me $you] (lazy.thaw calculation)]
@@ -94,35 +96,44 @@
#let [expectation (i/+ param subject)]]
($_ seq
(wrap (do promise.Monad<Promise>
- [$me ($me (#.Left id))
+ [## Add
+ $me ($me (#.Left id))
$me ($me param)
$me ($me subject)
- [output $end] ($me [])]
- (assert "Client [#Add]"
- (i/= expectation output))))
- (wrap (do promise.Monad<Promise>
- [add|<negate|quit> ($you [])]
- (case add|<negate|quit>
- (#.Left $add)
- (do @
- [[param-input $add] ($add [])
- [subject-input $add] ($add [])
- $recur ($add (i/+ param-input subject-input))]
- (assert "Server [#Add]"
- true))
+ [output $me] ($me [])
+ ## Negate
+ $me ($me (#.Right id))
+ $me ($me (#.Left id))
+ $me ($me output)
+ [-output $me] ($me [])
+ ## Quit
+ $me ($me (#.Right id))
+ $me ($me (#.Right id))]
+ (assert "Client [Add & Negate & Quit]"
+ (and (i/= expectation output)
+ (i/= (..negate expectation) -output)))))
+ (wrap (loop [$add|<negate|quit> $you]
+ (do promise.Monad<Promise>
+ [add|<negate|quit> ($add|<negate|quit> [])]
+ (case add|<negate|quit>
+ (#.Left $add)
+ (do @
+ [[param-input $add] ($add [])
+ [subject-input $add] ($add [])
+ $recur ($add (i/+ param-input subject-input))]
+ (recur $recur))
- (#.Right $negate|quit)
- (do @
- [negate|quit ($negate|quit [])]
- (case negate|quit
- (#.Left $negate)
- (do @
- [[subject $negate] ($negate [])
- $recur ($negate (i/* -1 subject))]
- (assert "Server [#Negate]"
- true))
+ (#.Right $negate|quit)
+ (do @
+ [negate|quit ($negate|quit [])]
+ (case negate|quit
+ (#.Left $negate)
+ (do @
+ [[subject $negate] ($negate [])
+ $recur ($negate (..negate subject))]
+ (recur $recur))
- (#.Right $quit)
- (assert "Server [#Quit]"
- true))))))
+ (#.Right $quit)
+ (assert "Server [Quit]"
+ true)))))))
)))