aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/concurrency/semaphore.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/control/concurrency/semaphore.lux17
1 files changed, 12 insertions, 5 deletions
diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux
index 472e21c7d..729e986c2 100644
--- a/stdlib/source/test/lux/control/concurrency/semaphore.lux
+++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux
@@ -1,6 +1,7 @@
(.module:
[lux #*
["_" test (#+ Test)]
+ ["@" target]
[abstract
["." monad (#+ do)]
["." enum]]
@@ -20,12 +21,18 @@
[math
["." random]
[number
- ["n" nat]]]
+ ["n" nat]
+ ["." i64]]]
[type
["." refinement]]]
{1
["." /]})
+(def: delay
+ (for {@.js
+ (i64.left_shift 4 1)}
+ (i64.left_shift 3 1)))
+
(def: semaphore
Test
(_.for [/.Semaphore]
@@ -34,7 +41,7 @@
[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 ..delay (/.wait semaphore))]
(_.cover' [/.semaphore]
(case result
(#.Some _)
@@ -47,7 +54,7 @@
#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))]
+ result (promise.time_out ..delay (/.wait semaphore))]
(_.cover' [/.wait]
(case result
(#.Some _)
@@ -61,9 +68,9 @@
(wrap (do {! promise.monad}
[_ (monad.map ! /.wait (list.repeat initial_open_positions semaphore))
#let [block (/.wait semaphore)]
- result/0 (promise.time_out 10 block)
+ result/0 (promise.time_out ..delay block)
open_positions (/.signal semaphore)
- result/1 (promise.time_out 10 block)]
+ result/1 (promise.time_out ..delay block)]
(_.cover' [/.signal]
(case [result/0 result/1 open_positions]
[#.None (#.Some _) (#try.Success +0)]