@@ -15,7 +15,7 @@ import Control.Concurrent.MVar
15 , takeMVar
15 , takeMVar
16 , readMVar
16 , readMVar
18−import Control.Monad (replicateM_, replicateM)
18+import Control.Monad (replicateM_, replicateM, forever)
19import Control.Exception (throwIO)
19import Control.Exception (throwIO)
20import Control.Applicative ((<$>), (<*>))
20import Control.Applicative ((<$>), (<*>))
21import qualified Network.Transport as NT (Transport, closeEndPoint)
21import qualified Network.Transport as NT (Transport, closeEndPoint)
@@ -660,6 +660,39 @@ testReconnect transport transportInternals = do
661 takeMVar registerTestOk
661 takeMVar registerTestOk
663+-- | Test 'matchAny'. This repeats the 'testMath' but with a proxy server
665+testMatchAny :: NT.Transport -> IO ()
666+testMatchAny transport = do
667+ proxyAddr <- newEmptyMVar
668+ clientDone <- newEmptyMVar
672+ localNode <- newLocalNode transport initRemoteTable
673+ mathServer <- forkProcess localNode math
674+ proxyServer <- forkProcess localNode $ forever $ do
675+ msg <- receiveWait [ matchAny return ]
676+ forward msg mathServer
677+ putMVar proxyAddr proxyServer
681+ localNode <- newLocalNode transport initRemoteTable
682+ mathServer <- readMVar proxyAddr
684+ runProcess localNode $ do
686+ send mathServer (Add pid 1 2)
687+ 3 <- expect :: Process Double
688+ send mathServer (Divide pid 8 2)
689+ 4 <- expect :: Process Double
690+ send mathServer (Divide pid 8 0)
692+ liftIO $ putMVar clientDone ()
663main :: IO ()
696main :: IO ()
665 Right (transport, transportInternals) <- createTransportExposeInternals "127.0.0.1" "8080" defaultTCPParameters
698 Right (transport, transportInternals) <- createTransportExposeInternals "127.0.0.1" "8080" defaultTCPParameters
@@ -675,6 +708,7 @@ main = do
675 , ("Registry", testRegistry transport)
708 , ("Registry", testRegistry transport)
676 , ("RemoteRegistry", testRemoteRegistry transport)
709 , ("RemoteRegistry", testRemoteRegistry transport)
677 , ("SpawnLocal", testSpawnLocal transport)
710 , ("SpawnLocal", testSpawnLocal transport)
711+ , ("MatchAny", testMatchAny transport)
678 -- Monitoring processes
712 -- Monitoring processes
680 -- The "missing" combinations in the list below don't make much sense, as
714 -- The "missing" combinations in the list below don't make much sense, as