diff options
Diffstat (limited to 'stdlib/source/test/lux/control/concurrency/semaphore.lux')
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/semaphore.lux | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 7e632b8cb..e30a930ac 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -31,10 +31,10 @@ (_.for [/.Semaphore] ($_ _.and (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do promise.monad - [result (promise.time-out 10 (/.wait semaphore))] + [result (promise.time_out 10 (/.wait semaphore))] (_.cover' [/.semaphore] (case result (#.Some _) @@ -43,11 +43,11 @@ #.None false))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) - result (promise.time-out 10 (/.wait semaphore))] + [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) + result (promise.time_out 10 (/.wait semaphore))] (_.cover' [/.wait] (case result (#.Some _) @@ -56,30 +56,30 @@ #.None true))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do {! promise.monad} - [_ (monad.map ! /.wait (list.repeat initial-open-positions semaphore)) + [_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore)) #let [block (/.wait semaphore)] - result/0 (promise.time-out 10 block) - open-positions (/.signal semaphore) - result/1 (promise.time-out 10 block)] + result/0 (promise.time_out 10 block) + open_positions (/.signal semaphore) + result/1 (promise.time_out 10 block)] (_.cover' [/.signal] - (case [result/0 result/1 open-positions] + (case [result/0 result/1 open_positions] [#.None (#.Some _) (#try.Success +0)] true _ false))))) (do {! random.monad} - [initial-open-positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) - #let [semaphore (/.semaphore initial-open-positions)]] + [initial_open_positions (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + #let [semaphore (/.semaphore initial_open_positions)]] (wrap (do promise.monad [outcome (/.signal semaphore)] - (_.cover' [/.semaphore-is-maxed-out] + (_.cover' [/.semaphore_is_maxed_out] (case outcome (#try.Failure error) - (exception.match? /.semaphore-is-maxed-out error) + (exception.match? /.semaphore_is_maxed_out error) _ false))))) @@ -92,8 +92,8 @@ (do {! random.monad} [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) #let [resource (atom.atom "") - expected-As (text.join-with "" (list.repeat repetitions "A")) - expected-Bs (text.join-with "" (list.repeat repetitions "B")) + expected_As (text.join_with "" (list.repeat repetitions "A")) + expected_Bs (text.join_with "" (list.repeat repetitions "B")) mutex (/.mutex []) processA (<| (/.synchronize mutex) io.io @@ -116,9 +116,9 @@ _ processB #let [outcome (io.run (atom.read resource))]] (_.cover' [/.mutex /.synchronize] - (or (text\= (format expected-As expected-Bs) + (or (text\= (format expected_As expected_Bs) outcome) - (text\= (format expected-Bs expected-As) + (text\= (format expected_Bs expected_As) outcome)))))) ))) @@ -142,7 +142,7 @@ [_ (#.Some limit)] (and (n.> 0 raw) - (n.= raw (refinement.un-refine limit))) + (n.= raw (refinement.un_refine limit))) _ false))) @@ -153,7 +153,7 @@ (wrap (do {! promise.monad} [#let [ending (|> "_" (list.repeat limit) - (text.join-with "")) + (text.join_with "")) ids (enum.range n.enum 0 (dec limit)) waiters (list\map (function (_ id) (exec (io.run (atom.update (|>> (format "_")) resource)) @@ -162,7 +162,7 @@ _ (monad.seq ! waiters) #let [outcome (io.run (atom.read resource))]] (_.cover' [/.barrier /.block] - (and (text.ends-with? ending outcome) + (and (text.ends_with? ending outcome) (list.every? (function (_ id) (text.contains? (%.nat id) outcome)) ids) |