summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2026-04-01 16:18:01 +0200
committerArnaud Bailly <arnaud@pankzsoft.com>2026-04-01 16:22:02 +0200
commitf6dde1041a52da4f2e7ccb77eed3c577f9d07798 (patch)
treeee99b8a606b7dcb378744f62245209a7d4d8eda4 /lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs
parentd820a635afb69c44f736e941bbe094ad6a838073 (diff)
downloadlambda-nantes-f6dde1041a52da4f2e7ccb77eed3c577f9d07798.tar.gz
Remove answers from sent challenges
Also fix integration test
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs')
-rw-r--r--lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs17
1 files changed, 14 insertions, 3 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs b/lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs
index ef05e20..d0265ac 100644
--- a/lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs
+++ b/lambda-calcul/haskell/test/Minilang/IntegrationSpec.hs
@@ -6,8 +6,12 @@ import Control.Exception (bracket)
import Data.Aeson (eitherDecodeFileStrict)
import Data.Proxy (Proxy (..))
import Data.Text (Text)
+import qualified Data.Text as Text
import Minilang.API
-import Minilang.REPL.Types (Evaluator (..))
+import Minilang.Lambda.Parser (pretty)
+import Minilang.REPL (withInput, withInputs)
+import Minilang.REPL.Purer (PurerEnv (..))
+import Minilang.REPL.Types (Command (Load), Content (..), Evaluator (..), In (Com), Out (..), initialREPL)
import Minilang.Server (Server (..), startServer, stopServer)
import Network.HTTP.Client (defaultManagerSettings, newManager)
import Servant.API ((:<|>) (..))
@@ -89,12 +93,19 @@ spec =
-- | Fetch the current challenge for the token, post the known answer, and
-- assert the server accepted it (200 OK / no exception).
solveChallenge :: ClientEnv -> Token -> Challenge -> IO ()
-solveChallenge env token Challenge{level, answer} = do
+solveChallenge env token Challenge{level, expr} = do
-- Confirm the server gives us the challenge we expect at this grade
Challenge{level = serverLevel} <- runC env $ challengeClient (Just token)
serverLevel `shouldBe` level
-- Post the correct answer
- runC env $ answerClient (Just token) answer
+ let PurerEnv{outputs} = withInputs initialREPL [Com (Load (Data expr))]
+ case outputs of
+ -- NOTE: Outputs are in reverse order, so the first output is the last one produced by the REPL.
+ (Bye : Evaluated ast _ _ : _) -> do
+ runC env $ answerClient (Just token) (pretty ast)
+ [Bye] ->
+ runC env $ answerClient (Just token) ""
+ answer -> fail $ "Unexpected answer format: " <> show answer
-- ---------------------------------------------------------------------------
-- Server lifecycle