From 16e0642ee4d09df1b032f8d30c7050cfac4d12f7 Mon Sep 17 00:00:00 2001 From: Arnaud Bailly Date: Mon, 3 Nov 2025 21:22:52 +0100 Subject: Handle :lang in REPL --- lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs | 20 ++++++++++++-------- lambda-calcul/haskell/test/Minilang/REPLSpec.hs | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'lambda-calcul/haskell/test/Minilang') diff --git a/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs b/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs index 076b073..b8f8b22 100644 --- a/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/REPL/NetSpec.hs @@ -6,8 +6,9 @@ import Control.Concurrent.STM.TVar import Control.Exception (bracket) import Control.Monad (forM) import Data.Aeson (eitherDecode, encode) -import Minilang.Lambda.Eval (newEnv) +import Minilang.Lambda.Eval (Term (..), newEnv) import Minilang.Lambda.Infer (newContext) +import Minilang.Lambda.Unify (Type (..)) import Minilang.Log import Minilang.REPL.Net import Minilang.REPL.Types @@ -65,16 +66,19 @@ temporaryFile = bracket newTempFile removeFile spec :: Spec spec = around withServer $ describe "MiniLang Network REPL" $ do - -- it "evaluates definition and returns defined symbol" $ \Server {serverPort} -> do - -- let inp = [In "Unit : U = Sum(tt)"] - -- expectedOutput = [Right $ Defined (B "Unit") (U 0)] - -- res <- runTestClient serverPort ".newenv1" inp + it "evaluates expression and returns evaluation result" $ \Server {serverPort} -> do + let inp = [In "((lam (x) x) y)"] + expectedOutput = [Right $ Evaluated (Var "y") (TyVar "b")] + res <- runTestClient serverPort ".newenv1" inp - -- res `shouldBe` expectedOutput + res `shouldBe` expectedOutput it "allows retrieving empty initial env" $ \Server {serverPort} -> do - let inp = [Com DumpEnv] - expectedOutput = [Right $ CurrentEnv newEnv newContext] + let inp = [Com (Set (SelectLanguage Untyped)), Com DumpEnv] + expectedOutput = + [ Right (Msg "Language set to Untyped"), + Right $ CurrentEnv newEnv newContext Untyped + ] res <- runTestClient serverPort ".newenv2" inp res `shouldBe` expectedOutput diff --git a/lambda-calcul/haskell/test/Minilang/REPLSpec.hs b/lambda-calcul/haskell/test/Minilang/REPLSpec.hs index d23ffbd..5469a59 100644 --- a/lambda-calcul/haskell/test/Minilang/REPLSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/REPLSpec.hs @@ -47,7 +47,8 @@ spec = parallel $ out `shouldBe` [ "Bye!", - "(lam (z s) (s ((lam (n z s) (s n)) (lam (z s) z)))) : " + "(lam (z s) (s ((lam (n z s) (s n)) (lam (z s) z)))) : ", + "Language set to Untyped" ] it "shows error when trying to load a non-existent file" $ do -- cgit v1.3.1