From 401b4c233d12763853877d4c31a2cf4342ca87b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 6 Jan 2026 22:29:07 +0100 Subject: =?UTF-8?q?Call=20stack=20for=20the=20=E2=80=98expect=E2=80=99=20s?= =?UTF-8?q?tatement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Parser/Statement.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Parser') diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs index 9b02770..0e6314b 100644 --- a/src/Parser/Statement.hs +++ b/src/Parser/Statement.hs @@ -169,6 +169,12 @@ instance ParamType SourceLine where parseParam _ = mzero showParamType _ = "" +instance ParamType CallStack where + type ParamRep CallStack = Expr CallStack + parseParam _ = mzero + showParamType _ = "" + paramExpr = id + instance ExprType a => ParamType (TypedVarName a) where parseParam _ = newVarName showParamType _ = "" @@ -269,6 +275,9 @@ paramOrContext name = fromParamOrContext <$> param name cmdLine :: CommandDef SourceLine cmdLine = param "" +callStack :: CommandDef CallStack +callStack = param "" + newtype InnerBlock a = InnerBlock { fromInnerBlock :: [ a ] -> TestBlock () } instance ExprType a => ParamType (InnerBlock a) where @@ -320,6 +329,7 @@ command name (CommandDef types ctor) = do iparams <- forM params $ \case (_, SomeParam (p :: Proxy p) Nothing) | Just (Refl :: p :~: SourceLine) <- eqT -> return $ SomeParam p $ Identity line + | Just (Refl :: p :~: CallStack) <- eqT -> return $ SomeParam p $ Identity $ Variable line callStackFqVarName | SomeNewVariables (vars :: [ TypedVarName a ]) <- definedVariables , Just (Refl :: p :~: InnerBlock a) <- eqT @@ -424,7 +434,8 @@ testSpawn = command "spawn" $ Spawn testExpect :: TestParser (Expr (TestBlock ())) testExpect = command "expect" $ Expect - <$> cmdLine + <$> callStack + <*> cmdLine <*> (fromExprParam <$> paramOrContext "from") <*> param "" <*> (maybe 1 fromExprParam <$> param "timeout") -- cgit v1.2.3