From 39cfe2035d8af4ec1edecccb2974d778dedc79b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 24 Sep 2025 11:01:52 +0000 Subject: [PATCH] test: freeze the callstack for better failure messages (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This would make the function `shouldLexTo` be transparent in the error reporting! Before all errors would point to this line. Reviewed-on: https://git.elland.me/elland/haddock2/pulls/1 Co-authored-by: Léana 江 Co-committed-by: Léana 江 --- test/Spec.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Spec.hs b/test/Spec.hs index d202ac2..0a7653d 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -11,6 +11,7 @@ import Types import Data.String (IsString (..)) import Data.Text (Text) import Text.Parsec.Pos +import GHC.Stack main :: IO () main = hspec $ do @@ -185,6 +186,7 @@ instance IsString (Doc String) where shouldLexTo :: String -> [(Int, Int, Token)] -> Expectation shouldLexTo input expected = + withFrozenCallStack $ case lexer input of Right tokens -> do let actual = map (\(pos, tok) -> (sourceLine pos, sourceColumn pos, tok)) tokens