test: changed HelloWorld input handling
authorMax Voit <max.voit+gtdv@with-eyes.net>
Mon, 22 Jun 2015 15:26:46 +0000 (17:26 +0200)
committerMax Voit <max.voit+gtdv@with-eyes.net>
Mon, 22 Jun 2015 15:26:46 +0000 (17:26 +0200)
test/HelloWorldMaster.hs
test/HelloWorldSlave.hs

index 2f40b31..b9a3ad4 100644 (file)
@@ -37,16 +37,15 @@ main = do acid <- openMasterState 3333 (HelloWorldState "Hello world")
           putStrLn "Possible commands: x for exit; q for query; uString for update;"
           forever $ do
               input <- getLine
-              let cmd = head input
-              case cmd of
-                    'x' -> do
+              case input of
+                    ('x':_) -> do
                         putStrLn "Bye!"
                         closeAcidState acid
                         exitSuccess
-                    'q' -> do
+                    ('q':_) -> do
                         string <- query acid QueryState
                         putStrLn $ "The state is: " ++ string
-                    'u' -> do
-                        update acid (WriteState (tail input))
+                    ('u':str) -> do
+                        update acid (WriteState str)
                         putStrLn "The state has been modified!"
                     _   -> putStrLn $ "Unknown command " ++ input
index c0a30df..f0ded48 100644 (file)
@@ -37,16 +37,15 @@ main = do acid <- enslaveState "localhost"  3333 (HelloWorldState "Hello world")
           putStrLn "Possible commands: x for exit; q for query; uString for update;"
           forever $ do
               input <- getLine
-              let cmd = head input
-              case cmd of
-                    'x' -> do
+              case input of
+                    ('x':_) -> do
                         putStrLn "Bye!"
                         closeAcidState acid
                         exitSuccess
-                    'q' -> do
+                    ('q':_) -> do
                         string <- query acid QueryState
                         putStrLn $ "The state is: " ++ string
-                    'u'  -> do
-                        update acid (WriteState (tail input))
+                    ('u':str) -> do
+                        update acid (WriteState str)
                         putStrLn "The state has been modified!"
                     _   -> putStrLn $ "Unknown command " ++ input