diff options
Diffstat (limited to 'stdlib/source/test/lux/control/concurrency/semaphore.lux')
-rw-r--r-- | stdlib/source/test/lux/control/concurrency/semaphore.lux | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 729e986c2..a8e64124c 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -154,26 +154,26 @@ _ false))) (do {! random.monad} - [limit (|> random.nat (\ ! map (|>> (n.% 10) (n.max 1)))) + [limit (\ ! map (|>> (n.% 9) inc) random.nat) #let [barrier (/.barrier (maybe.assume (/.limit limit))) resource (atom.atom "")]] (wrap (do {! promise.monad} - [#let [ending (|> "_" - (list.repeat limit) - (text.join_with "")) - ids (enum.range n.enum 0 (dec limit)) - waiters (list\map (function (_ id) - (exec (io.run (atom.update (|>> (format "_")) resource)) - (waiter resource barrier id))) - ids)] - _ (monad.seq ! waiters) + [#let [suffix "_" + expected_ending (|> suffix + (list.repeat limit) + (text.join_with "")) + expected_ids (enum.range n.enum 0 (dec limit))] + _ (|> expected_ids + (list\map (function (_ id) + (exec (io.run (atom.update (|>> (format suffix)) resource)) + (waiter resource barrier id)))) + (monad.seq !)) #let [outcome (io.run (atom.read resource))]] (_.cover' [/.barrier /.block] - (and (text.ends_with? ending outcome) + (and (text.ends_with? expected_ending outcome) (list.every? (function (_ id) (text.contains? (%.nat id) outcome)) - ids) - ))))) + expected_ids)))))) ))) (def: #export test |