@@ -15,7 +15,7 @@ import qualified Control.Distributed.Process.Extras (__remoteTable)
1515import Control.Distributed.Process.Extras.Time hiding (timeout )
1616import Control.Distributed.Process.Extras.Timer
1717import Control.Distributed.Process.FSM
18- import Control.Distributed.Process.FSM.Client (call )
18+ import Control.Distributed.Process.FSM.Client (call , callTimeout )
1919import Control.Distributed.Process.FSM.Internal.Process
2020import Control.Distributed.Process.FSM.Internal.Types hiding (State , liftIO )
2121import Control.Distributed.Process.SysTest.Utils
@@ -37,6 +37,7 @@ import qualified Network.Transport as NT
3737-- import Control.Distributed.Process.Serializable (Serializable)
3838-- import Control.Monad (void)
3939import Data.Binary (Binary )
40+ import Data.Maybe (fromJust )
4041import Data.Typeable (Typeable )
4142import GHC.Generics
4243
@@ -104,8 +105,11 @@ deepFSM :: SendPort () -> SendPort () -> Step State ()
104105deepFSM on off = initState Off ()
105106 ^. ((event :: Event State ) ~> (allState $ \ s -> enter s))
106107 .| ( (Off ~@ resume)
107- |> ((event :: Event () )
108- ~> (allState $ \ s -> (lift $ sendChan off s) >> resume))
108+ |> ( ((event :: Event () )
109+ ~> (allState $ \ s -> (lift $ sendChan off s) >> resume))
110+ .| (((event :: Event String ) ~> (always $ \ (_ :: String ) -> resume))
111+ |> (reply (currentInput >>= return . fromJust :: FSM State () String )))
112+ )
109113 )
110114 .| ( (On ~@ resume)
111115 |> ((event :: Event () )
@@ -129,11 +133,17 @@ verifyOuterStateHandler = do
129133 Nothing <- receiveChanTimeout (asTimeout $ seconds 3 ) rpOff
130134 () <- receiveChan rpOn
131135
136+ resp <- callTimeout pid " hello there" (seconds 3 ):: Process (Maybe String )
137+ resp `shouldBe` equalTo (Nothing :: Maybe String )
138+
132139 send pid Off
133140 send pid ()
134141 Nothing <- receiveChanTimeout (asTimeout $ seconds 3 ) rpOn
135142 () <- receiveChan rpOff
136143
144+ res <- call pid " hello" :: Process String
145+ res `shouldBe` equalTo " hello"
146+
137147 kill pid " bye bye"
138148
139149verifyMailboxHandling :: Process ()
0 commit comments