aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/concurrency
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/control/concurrency')
-rw-r--r--stdlib/source/test/lux/control/concurrency/actor.lux26
-rw-r--r--stdlib/source/test/lux/control/concurrency/async.lux18
-rw-r--r--stdlib/source/test/lux/control/concurrency/frp.lux34
-rw-r--r--stdlib/source/test/lux/control/concurrency/semaphore.lux24
-rw-r--r--stdlib/source/test/lux/control/concurrency/stm.lux4
5 files changed, 53 insertions, 53 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux
index 627b294ad..93c68faff 100644
--- a/stdlib/source/test/lux/control/concurrency/actor.lux
+++ b/stdlib/source/test/lux/control/concurrency/actor.lux
@@ -55,8 +55,8 @@
(function (_ transform)
(function (_ state actor)
(|> state transform #try.Success async\in))))
- inc! (: (/.Mail Nat) (as_mail inc))
- dec! (: (/.Mail Nat) (as_mail dec))]]
+ ++! (: (/.Mail Nat) (as_mail ++))
+ --! (: (/.Mail Nat) (as_mail --))]]
(<| (_.covering /._)
(_.for [/.Actor])
($_ _.and
@@ -116,7 +116,7 @@
(in (do async.monad
[sent? (async.future (do io.monad
[actor (/.spawn! /.default 0)
- sent? (/.mail! inc! actor)]
+ sent? (/.mail! ++! actor)]
(in (..mailed? sent?))))]
(_.cover' [/.Behavior /.Mail
/.default /.spawn! /.mail!]
@@ -126,7 +126,7 @@
[result (async.future (do io.monad
[counter (/.spawn! /.default 0)
_ (/.poison! counter)]
- (/.mail! inc! counter)))]
+ (/.mail! ++! counter)))]
(_.cover' [/.dead]
(case result
(#try.Success outcome)
@@ -180,18 +180,18 @@
[anonymous (/.actor {Nat
initial_state}
((on_mail message state self)
- (message (inc state) self)))
- sent/inc? (/.mail! inc! anonymous)
- sent/dec? (/.mail! dec! anonymous)
+ (message (++ state) self)))
+ sent/++? (/.mail! ++! anonymous)
+ sent/--? (/.mail! --! anonymous)
poisoned? (/.poison! anonymous)
obituary (/.obituary' anonymous)]
- (in (and (..mailed? sent/inc?)
- (..mailed? sent/dec?)
+ (in (and (..mailed? sent/++?)
+ (..mailed? sent/--?)
(..mailed? poisoned?)
(case obituary
(^ (#.Some [error final_state (list poison_pill)]))
(and (exception.match? /.poisoned error)
- (n.= (inc (inc initial_state))
+ (n.= (++ (++ initial_state))
final_state))
_
@@ -200,7 +200,7 @@
verdict)))
(do !
- [num_events (\ ! map (|>> (n.% 10) inc) random.nat)
+ [num_events (\ ! map (|>> (n.% 10) ++) random.nat)
events (random.list num_events random.nat)
num_observations (\ ! map (n.% num_events) random.nat)
.let [expected (list.first num_observations events)
@@ -215,8 +215,8 @@
(async.future
(if (n.< num_observations events_seen)
(do !
- [_ (atom.update! (row.add event) sink)]
- (in (#try.Success (inc events_seen))))
+ [_ (atom.update! (row.suffix event) sink)]
+ (in (#try.Success (++ events_seen))))
(do !
[_ stop]
(in (#try.Failure "YOLO")))))))
diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux
index a92a5c44c..f9b917ee5 100644
--- a/stdlib/source/test/lux/control/concurrency/async.lux
+++ b/stdlib/source/test/lux/control/concurrency/async.lux
@@ -107,16 +107,16 @@
(n.+ leftA rightA)))))
(in (do /.monad
[pre (/.future instant.now)
- actual (/.delayed waiting_time expected)
+ actual (/.after waiting_time expected)
post (/.future instant.now)]
- (_.cover' [/.delayed]
+ (_.cover' [/.after]
(and (n.= expected actual)
(i.>= (.int waiting_time)
(duration.millis (instant.span pre post)))))))
(in (do /.monad
[?left (/.or (in leftE)
- (/.delayed waiting_time dummy))
- ?right (/.or (/.delayed waiting_time dummy)
+ (/.after waiting_time dummy))
+ ?right (/.or (/.after waiting_time dummy)
(in rightE))]
(_.cover' [/.or]
(case [?left ?right]
@@ -128,8 +128,8 @@
false))))
(in (do /.monad
[leftA (/.either (in leftE)
- (/.delayed waiting_time dummy))
- rightA (/.either (/.delayed waiting_time dummy)
+ (/.after waiting_time dummy))
+ rightA (/.either (/.after waiting_time dummy)
(in rightE))]
(_.cover' [/.either]
(n.= (n.+ leftE rightE)
@@ -155,9 +155,9 @@
(and yep
(not nope)))))
(in (do /.monad
- [?none (/.time_out 0 (/.delayed waiting_time dummy))
- ?actual (/.time_out waiting_time (in expected))]
- (_.cover' [/.time_out]
+ [?none (/.within 0 (/.after waiting_time dummy))
+ ?actual (/.within waiting_time (in expected))]
+ (_.cover' [/.within]
(case [?none ?actual]
[#.None (#.Some actual)]
(n.= expected actual)
diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux
index 45dadc8cb..5876331b6 100644
--- a/stdlib/source/test/lux/control/concurrency/frp.lux
+++ b/stdlib/source/test/lux/control/concurrency/frp.lux
@@ -60,7 +60,7 @@
(#.Some [head tail])
(\ ! map (|>> (#.Item head))
- (take_amount (dec amount_of_polls) [channel sink]))))))
+ (take_amount (-- amount_of_polls) [channel sink]))))))
(def: .public test
Test
@@ -145,9 +145,9 @@
_ (async.future (/.subscribe! (function (_ value)
(do {! io.monad}
[current (atom.read! sink)
- _ (atom.update! (row.add value) sink)]
+ _ (atom.update! (row.suffix value) sink)]
(if (n.< (list.size inputs)
- (inc (row.size current)))
+ (++ (row.size current)))
(in (#.Some []))
(do !
[_ (!signal [])]
@@ -161,22 +161,22 @@
(_.cover' [/.Subscriber /.subscribe!]
(list\= inputs listened))))
(in (do async.monad
- [actual (/.fold (function (_ input total)
- (async.resolved (n.+ input total)))
- 0
- (/.sequential 0 inputs))]
- (_.cover' [/.fold]
+ [actual (/.aggregate (function (_ input total)
+ (async.resolved (n.+ input total)))
+ 0
+ (/.sequential 0 inputs))]
+ (_.cover' [/.aggregate]
(n.= (list\fold n.+ 0 inputs)
actual))))
(in (do async.monad
[actual (|> inputs
(/.sequential 0)
- (/.folds (function (_ input total)
- (async.resolved (n.+ input total)))
- 0)
+ (/.aggregates (function (_ input total)
+ (async.resolved (n.+ input total)))
+ 0)
/.list)]
- (_.cover' [/.folds]
- (list\= (list.folds n.+ 0 inputs)
+ (_.cover' [/.aggregates]
+ (list\= (list.aggregates n.+ 0 inputs)
actual))))
(in (do async.monad
[actual (|> (list distint/0 distint/0 distint/0
@@ -189,8 +189,8 @@
(list\= (list distint/0 distint/1 distint/2)
actual))))
(do !
- [polling_delay (\ ! map (|>> (n.% 10) inc) random.nat)
- amount_of_polls (\ ! map (|>> (n.% 10) inc) random.nat)]
+ [polling_delay (\ ! map (|>> (n.% 10) ++) random.nat)
+ amount_of_polls (\ ! map (|>> (n.% 10) ++) random.nat)]
($_ _.and
(in (do {! async.monad}
[actual (..take_amount amount_of_polls (/.poll polling_delay (: (IO Nat) (io.io sample))))
@@ -212,12 +212,12 @@
(/.iterations (function (_ [iterations current])
(async.resolved
(if (n.< max_iterations iterations)
- (#.Some [[(inc iterations) (n.+ shift current)]
+ (#.Some [[(++ iterations) (n.+ shift current)]
current])
#.None))))
/.list)]
(_.cover' [/.iterations]
(and (n.= max_iterations (list.size actual))
- (list\= (list.folds n.+ sample (list.repeated (dec max_iterations) shift))
+ (list\= (list.aggregates n.+ sample (list.repeated (-- max_iterations) shift))
actual)))))
)))))
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux
index a57e3bcd6..b4b07bbb0 100644
--- a/stdlib/source/test/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux
@@ -42,7 +42,7 @@
[initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1))))
.let [semaphore (/.semaphore initial_open_positions)]]
(in (do async.monad
- [result (async.time_out ..delay (/.wait! semaphore))]
+ [result (async.within ..delay (/.wait! semaphore))]
(_.cover' [/.semaphore]
(case result
(#.Some _)
@@ -55,7 +55,7 @@
.let [semaphore (/.semaphore initial_open_positions)]]
(in (do {! async.monad}
[_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore))
- result (async.time_out ..delay (/.wait! semaphore))]
+ result (async.within ..delay (/.wait! semaphore))]
(_.cover' [/.wait!]
(case result
(#.Some _)
@@ -69,9 +69,9 @@
(in (do {! async.monad}
[_ (monad.map ! /.wait! (list.repeated initial_open_positions semaphore))
.let [block (/.wait! semaphore)]
- result/0 (async.time_out ..delay block)
+ result/0 (async.within ..delay block)
open_positions (/.signal! semaphore)
- result/1 (async.time_out ..delay block)]
+ result/1 (async.within ..delay block)]
(_.cover' [/.signal!]
(case [result/0 result/1 open_positions]
[#.None (#.Some _) (#try.Success +0)]
@@ -100,14 +100,14 @@
(do {! random.monad}
[repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10))))
.let [resource (atom.atom "")
- expected_As (text.joined (list.repeated repetitions "A"))
- expected_Bs (text.joined (list.repeated repetitions "B"))
+ expected_As (text.together (list.repeated repetitions "A"))
+ expected_Bs (text.together (list.repeated repetitions "B"))
mutex (/.mutex [])
processA (<| (/.synchronize! mutex)
io.io
async.future
(do {! io.monad}
- [_ (<| (monad.seq !)
+ [_ (<| (monad.all !)
(list.repeated repetitions)
(atom.update! (|>> (format "A")) resource))]
(in [])))
@@ -115,7 +115,7 @@
io.io
async.future
(do {! io.monad}
- [_ (<| (monad.seq !)
+ [_ (<| (monad.all !)
(list.repeated repetitions)
(atom.update! (|>> (format "B")) resource))]
(in [])))]]
@@ -155,21 +155,21 @@
_
false)))
(do {! random.monad}
- [limit (\ ! map (|>> (n.% 9) inc) random.nat)
+ [limit (\ ! map (|>> (n.% 9) ++) random.nat)
.let [barrier (/.barrier (maybe.trusted (/.limit limit)))
resource (atom.atom "")]]
(in (do {! async.monad}
[.let [suffix "_"
expected_ending (|> suffix
(list.repeated limit)
- text.joined)
- expected_ids (enum.range n.enum 0 (dec limit))]
+ text.together)
+ expected_ids (enum.range n.enum 0 (-- limit))]
_ (|> expected_ids
(list\map (function (_ id)
(exec
(io.run! (atom.update! (|>> (format suffix)) resource))
(waiter resource barrier id))))
- (monad.seq !))
+ (monad.all !))
.let [outcome (io.run! (atom.read! resource))]]
(_.cover' [/.barrier /.block!]
(and (text.ends_with? expected_ending outcome)
diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux
index dbe98177f..f3a5c618c 100644
--- a/stdlib/source/test/lux/control/concurrency/stm.lux
+++ b/stdlib/source/test/lux/control/concurrency/stm.lux
@@ -94,8 +94,8 @@
(in (let [var (/.var 0)]
(do {! async.monad}
[_ (|> (list.repeated iterations_per_process [])
- (list\map (function (_ _) (/.commit! (/.update inc var))))
- (monad.seq !))
+ (list\map (function (_ _) (/.commit! (/.update ++ var))))
+ (monad.all !))
cummulative (/.commit! (/.read var))]
(_.cover' [/.STM]
(n.= iterations_per_process