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 --- lambda-calcul/haskell/test/Minilang/ServerSpec.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lambda-calcul/haskell/test/Minilang/ServerSpec.hs') diff --git a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs index 2860c40..8d0b182 100644 --- a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs @@ -51,7 +51,7 @@ spec = with (app testSeed) $ do it "GET /api/leaderboard returns empty list of scores at start" $ do get "/api/leaderboard" - `shouldRespondWith` 200 {matchBody = arrayOfLengthOf (Proxy @Score) 0} + `shouldRespondWith` 200{matchBody = arrayOfLengthOf (Proxy @Score) 0} it "POST /api/register returns registration token given user is not registered" $ do postJSON "/api/register" alice @@ -66,7 +66,7 @@ spec = with (app testSeed) $ do it "GET /api/leaderboard returns list of one element after user registers" $ do void $ postJSON "/api/register" alice get "/api/leaderboard" - `shouldRespondWith` 200 {matchBody = arrayOfLengthOf (Proxy @Score) 1} + `shouldRespondWith` 200{matchBody = arrayOfLengthOf (Proxy @Score) 1} it "POST /api/register returns 400 given user is already registered" $ do void $ postJSON "/api/register" alice @@ -84,7 +84,7 @@ spec = with (app testSeed) $ do `shouldRespondWith` 404 it "GET /api/challenge returns next challenge given user is registered" $ do - let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge {level = 0, expr = "x", description = "A lone free variable. What does x reduce to?", answer = "x"} + let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge{level = 0, expr = "x", description = "A lone free variable. What does x reduce to?"} postJSON "/api/register" alice `shouldRespondWith` 201 @@ -123,7 +123,7 @@ spec = with (app testSeed) $ do `shouldRespondWith` 400 it "GET /api/challenge returns next level challenge after successful POST" $ do - let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge {level = 1, expr = "y", description = "Another free variable. What does y reduce to?", answer = "y"} + let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge{level = 1, expr = "y", description = "Another free variable. What does y reduce to?"} void $ postJSON "/api/register" alice void $ postJSON ("/api/challenge?token=" <> LBS.toStrict token) "\"x\"" @@ -147,7 +147,7 @@ spec = with (app testSeed) $ do { matchBody = MatchBody $ \_ actual -> case eitherDecode actual of Right (score :: Score) -> - if score == Score {user = User "alice", grade = 0, lastTest = Nothing, lastResult = Nothing} + if score == Score{user = User "alice", grade = 0, lastTest = Nothing, lastResult = Nothing} then Nothing else Just $ "Expected score with grade 0, but got " ++ show score Left err -> Just $ "Failed to decode JSON: " ++ err @@ -190,7 +190,7 @@ spec = with (app testSeed) $ do postJSON :: BS.ByteString -> ByteString -> WaiSession () SResponse postJSON url = request "POST" url [("Content-Type", "application/json")] -arrayOfLengthOf :: forall elem proxy. (FromJSON elem) => proxy elem -> Int -> MatchBody +arrayOfLengthOf :: forall elem proxy. FromJSON elem => proxy elem -> Int -> MatchBody arrayOfLengthOf _ len = MatchBody $ \_ actual -> case eitherDecode actual of Right (scores :: [elem]) -> -- cgit v1.3.1