1 IN: concurrency.combinators.tests
\r
2 USING: concurrency.combinators tools.test random kernel math
\r
3 concurrency.mailboxes threads sequences accessors arrays
\r
6 [ [ drop ] parallel-each ] must-infer
\r
7 { 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as
\r
8 [ [ ] parallel-map ] must-infer
\r
9 { 2 1 } [ [ 2array ] 2parallel-map ] must-infer-as
\r
10 [ [ ] parallel-filter ] must-infer
\r
12 [ { 1 4 9 } ] [ { 1 2 3 } [ sq ] parallel-map ] unit-test
\r
14 [ { 1 4 9 } ] [ { 1 2 3 } [ 1000000 random sleep sq ] parallel-map ] unit-test
\r
16 [ { 1 2 3 } [ dup 2 mod 0 = [ "Even" throw ] when ] parallel-map ]
\r
17 [ error>> "Even" = ] must-fail-with
\r
20 [ 10 [ 3 mod zero? ] parallel-filter ] unit-test
\r
25 10 over [ push ] curry parallel-each
\r
30 { 1 4 3 } { 10 5 10 } [ * ] 2parallel-map
\r
34 { 1 4 3 } { 10 5 10 } [ - ] 2parallel-map
\r
38 { 1 4 3 } { 1 0 1 } [ / drop ] 2parallel-each
\r
44 10 10 pick [ [ push ] [ push ] bi ] curry 2parallel-each
\r
48 [ { f } [ "OOPS" throw ] parallel-each ] must-fail
\r
50 [ "1a" "4b" "3c" ] [
\r
52 { [ 1- ] [ sq ] [ 1+ ] } parallel-cleave
\r
53 [ number>string ] 3 parallel-napply
\r
54 { [ "a" append ] [ "b" append ] [ "c" append ] } parallel-spread
\r