aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux/concurrency/session.lux139
1 files changed, 0 insertions, 139 deletions
diff --git a/stdlib/test/test/lux/concurrency/session.lux b/stdlib/test/test/lux/concurrency/session.lux
deleted file mode 100644
index ed538372c..000000000
--- a/stdlib/test/test/lux/concurrency/session.lux
+++ /dev/null
@@ -1,139 +0,0 @@
-(.module:
- [lux #*
- [control
- [monad (#+ do)]]
- [data
- ["." lazy (#+ Lazy)]]
- ["." io (#+ IO)]
- [concurrency
- ["." promise]
- ["$" session (#+ Session << >> ?? !! +<< -<< \/ /\ $rec)]]
- [data
- [text
- format]]
- [math
- ["r" random]]]
- lux/test)
-
-(def: $transfer (<| << (!! Int) >>))
-
-(def: transfer
- (IO (:~ $transfer))
- (io.io (lazy.thaw (<| $.send $.end))))
-
-(context: "Transfer."
- (do @
- [#let [[$me $you] (io.run ..transfer)]
- expectation r.int]
- ($_ seq
- (wrap (do promise.Monad<Promise>
- [$me ($me expectation)]
- (assert "Client [Transfer]"
- true)))
- (wrap (do promise.Monad<Promise>
- [[actual $end] ($you [])]
- (assert "Server [Transfer]"
- (i/= expectation actual))))
- )))
-
-(def: $endless
- (<< ($rec (function (_ $recur)
- (<| (!! Int) $recur)))))
-
-(def: endless
- (IO (:~ $endless))
- (io.io (lazy.thaw ($.rec (function (_ recur)
- (<| $.send recur))))))
-
-(context: "Endless."
- (do @
- [#let [[$me $you] (io.run ..endless)]
- expectation0 r.int
- expectation1 r.int
- expectation2 r.int]
- ($_ seq
- (wrap (do promise.Monad<Promise>
- [$me ($me expectation0)
- $me ($me expectation1)
- $me ($me expectation2)]
- (assert "Client [Endless]"
- true)))
- (wrap (do promise.Monad<Promise>
- [[actual0 $you] ($you [])
- [actual1 $you] ($you [])
- [actual2 $you] ($you [])]
- (assert "Server [Endless]"
- (and (i/= expectation0 actual0)
- (i/= expectation1 actual1)
- (i/= expectation2 actual2)))))
- )))
-
-(def: $calculation
- Session
- ($rec
- (function (_ $recur)
- ($_ \/
- (<| (!! Int) (!! Int) (?? Int) $recur)
- (<| (!! Int) (?? Int) $recur)
- >>))))
-
-(def: calculation
- (IO (:~ (<< $calculation)))
- (io.io (lazy.thaw ($.rec
- (function (_ recur)
- ($_ $.fork
- (<| $.send $.send $.receive recur)
- (<| $.send $.receive recur)
- $.end))))))
-
-(def: negate (i/* -1))
-
-(context: "Complex session."
- (do @
- [#let [[$me $you] (io.run calculation)]
- param r.int
- subject r.int
- #let [expectation (i/+ param subject)]]
- ($_ seq
- (wrap (do promise.Monad<Promise>
- [## Add
- $me ($me (#.Left id))
- $me ($me param)
- $me ($me subject)
- [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 (..negate subject))]
- (recur $recur))
-
- (#.Right $quit)
- (assert "Server [Quit]"
- true)))))))
- )))