From f6dde1041a52da4f2e7ccb77eed3c577f9d07798 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Wed, 1 Apr 2026 16:18:01 +0200 Subject: Remove answers from sent challenges Also fix integration test --- .../haskell/test/Minilang/REPL/NetSpec.hs | 45 +++++++++++----------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'lambda-calcul/haskell/test/Minilang/REPL') diff --git a/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs b/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs index 6a2b1ab..2f8880a 100644 --- a/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs @@ -1,6 +1,5 @@ module Minilang.REPL.NetSpec where --- import Control.Concurrent (threadDelay) import Control.Concurrent.Async import Control.Concurrent.STM.TVar import Control.Exception (bracket) @@ -46,48 +45,48 @@ withServer = runTestClient :: Int -> String -> [In] -> IO [Either String Out] runTestClient port envId inputs = runClient "127.0.0.1" port ("/repl/" <> envId) client - where - client cnx = do - outs <- forM inputs $ \inp -> do - WS.sendBinaryData cnx (encode inp) - eitherDecode <$> WS.receiveData cnx - WS.sendBinaryData cnx (encode EOF) - WS.sendClose cnx (encode ("" :: String)) - pure outs + where + client cnx = do + outs <- forM inputs $ \inp -> do + WS.sendBinaryData cnx (encode inp) + eitherDecode <$> WS.receiveData cnx + WS.sendBinaryData cnx (encode EOF) + WS.sendClose cnx (encode ("" :: String)) + pure outs temporaryFile :: (FilePath -> IO c) -> IO c temporaryFile = bracket newTempFile removeFile - where - newTempFile = do - dir <- getTemporaryDirectory - (f, h) <- mkstemp (dir "repl.test") - hClose h - pure f + where + newTempFile = do + dir <- getTemporaryDirectory + (f, h) <- mkstemp (dir "repl.test") + hClose h + pure f spec :: Spec spec = around withServer $ describe "MiniLang Network REPL" $ do - it "evaluates expression and returns evaluation result" $ \Server {serverPort} -> do + it "evaluates expression and returns evaluation result" $ \Server{serverPort} -> do let inp = [Com (Set (SelectLanguage Typed)), In "((lam (x) x) y)"] expectedOutput = - [ Right (Msg "Language set to Typed"), - Right $ Evaluated (AST.Sym "y") (Var "y") (TyVar "a") + [ Right (Msg "Language set to Typed") + , Right $ Evaluated (AST.Sym "y") (Var "y") (Just $ TyVar "a") ] res <- runTestClient serverPort ".newenv1" inp res `shouldBe` expectedOutput - it "allows retrieving empty initial env" $ \Server {serverPort} -> do + it "allows retrieving empty initial env" $ \Server{serverPort} -> do let inp = [Com (Set (SelectLanguage Typed)), Com DumpEnv] expectedOutput = - [ Right (Msg "Language set to Typed"), - Right $ CurrentEnv newEnv newContext Typed + [ Right (Msg "Language set to Typed") + , Right $ CurrentEnv newEnv newContext Typed ] res <- runTestClient serverPort ".newenv2" inp res `shouldBe` expectedOutput - it "can reconnect to existing environment" $ \Server {serverPort} -> do + it "can reconnect to existing environment" $ \Server{serverPort} -> do let inp = [In "Unit : U = Sum(tt)"] _ <- runTestClient serverPort ".newenv3" inp res <- runTestClient serverPort ".newenv3" [In "Unit"] @@ -95,5 +94,5 @@ spec = around withServer $ res `shouldSatisfy` isEvaluated isEvaluated :: [Either a Out] -> Bool -isEvaluated [Right (Evaluated _ _ _)] = True +isEvaluated [Right Evaluated{}] = True isEvaluated _ = False -- cgit v1.3.1