]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/concurrency/exchangers/exchangers-tests.factor
factor: trim using lists
[factor.git] / basis / concurrency / exchangers / exchangers-tests.factor
index a8214cf42f2301a5712a034df555f20053c3bbf3..b3a8fee8b2ecd0c1155300845dc5e4a75d28975d 100644 (file)
@@ -1,31 +1,29 @@
-USING: tools.test concurrency.exchangers\r
-concurrency.count-downs concurrency.promises locals kernel\r
-threads ;\r
-FROM: sequences => 3append ;\r
-IN: concurrency.exchangers.tests\r
-\r
-:: exchanger-test ( -- string )\r
-    [let |\r
-        ex [ <exchanger> ]\r
-        c [ 2 <count-down> ]\r
-        v1! [ f ]\r
-        v2! [ f ]\r
-        pr [ <promise> ] |\r
-\r
-        [\r
-            c await\r
-            v1 ", " v2 3append pr fulfill\r
-        ] "Awaiter" spawn drop\r
-\r
-        [\r
-            "Goodbye world" ex exchange v1! c count-down\r
-        ] "Exchanger 1" spawn drop\r
-\r
-        [\r
-            "Hello world" ex exchange v2! c count-down\r
-        ] "Exchanger 2" spawn drop\r
-\r
-        pr ?promise\r
-    ] ;\r
-\r
-[ "Hello world, Goodbye world" ] [ exchanger-test ] unit-test\r
+USING: tools.test concurrency.exchangers
+concurrency.count-downs concurrency.promises kernel
+threads ;
+FROM: sequences => 3append ;
+IN: concurrency.exchangers.tests
+
+:: exchanger-test ( -- string )
+    <exchanger> :> ex
+    2 <count-down> :> c
+    f :> v1!
+    f :> v2!
+    <promise> :> pr
+
+    [
+        c await
+        v1 ", " v2 3append pr fulfill
+    ] "Awaiter" spawn drop
+
+    [
+        "Goodbye world" ex exchange v1! c count-down
+    ] "Exchanger 1" spawn drop
+
+    [
+        "Hello world" ex exchange v2! c count-down
+    ] "Exchanger 2" spawn drop
+
+    pr ?promise ;
+
+{ "Hello world, Goodbye world" } [ exchanger-test ] unit-test