[MLton-commit] r5342
Vesa Karvonen
vesak at mlton.org
Mon Feb 26 15:19:54 PST 2007
Another test.
----------------------------------------------------------------------
U mltonlib/trunk/com/ssh/async/unstable/test/async.sml
----------------------------------------------------------------------
Modified: mltonlib/trunk/com/ssh/async/unstable/test/async.sml
===================================================================
--- mltonlib/trunk/com/ssh/async/unstable/test/async.sml 2007-02-26 22:58:54 UTC (rev 5341)
+++ mltonlib/trunk/com/ssh/async/unstable/test/async.sml 2007-02-26 23:19:54 UTC (rev 5342)
@@ -32,5 +32,24 @@
; eq (!n, 2)
end))
+ (title "Async.Event.choose")
+
+ (test (fn () => let
+ val b1 = Mailbox.new ()
+ val b2 = Mailbox.new ()
+ val n = ref 0
+ val e = choose [on (Mailbox.take b1, inc n),
+ on (Mailbox.take b2, inc n)]
+ in
+ Mailbox.send b1 ()
+ ; Mailbox.send b1 ()
+ ; Mailbox.send b2 ()
+ ; once e ; eq (!n, 0)
+ ; Handler.runAll () ; eq (!n, 1)
+ ; each e ; eq (!n, 1)
+ ; Handler.runAll () ; eq (!n, 3)
+ ; Handler.runAll () ; eq (!n, 3)
+ end))
+
$
end
More information about the MLton-commit
mailing list