diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-09-23 19:44:17 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-09-25 20:25:22 +0200 |
commit | 213e3523aead4c18b65ac85886203d2508b9b27e (patch) | |
tree | 6f207174a09ee312a366d0c22c08a31a056aaf3d /src/Run.hs | |
parent | 274554243235d3013430a48973fd0f25244ac392 (diff) |
Implement "guard" as a builtin
Diffstat (limited to 'src/Run.hs')
-rw-r--r-- | src/Run.hs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -188,7 +188,7 @@ evalSteps = mapM_ $ \case withVar :: ExprType e => VarName -> e -> TestRun a -> TestRun a -withVar name value = local (fmap $ \s -> s { tsVars = ( name, SomeVarValue mempty $ const value ) : tsVars s }) +withVar name value = local (fmap $ \s -> s { tsVars = ( name, SomeVarValue mempty $ const $ const value ) : tsVars s }) withInternet :: (Network -> TestRun a) -> TestRun a withInternet inner = do @@ -280,7 +280,10 @@ exprFailed desc (SourceLine sline) pname expr = do exprVars <- gatherVars expr outLine OutputMatchFail (Just prompt) $ T.concat [desc, T.pack " failed on ", sline] forM_ exprVars $ \((name, sel), value) -> - outLine OutputMatchFail (Just prompt) $ T.concat [" ", textVarName name, T.concat (map ("."<>) sel), " = ", textSomeVarValue value] + outLine OutputMatchFail (Just prompt) $ T.concat + [ " ", textVarName name, T.concat (map ("."<>) sel) + , " = ", textSomeVarValue (SourceLine sline) value + ] throwError Failed expect :: SourceLine -> Process -> Expr Regex -> [TypedVarName Text] -> TestRun () -> TestRun () @@ -310,7 +313,7 @@ expect (SourceLine sline) p expr tvars inner = do throwError Failed outProc OutputMatch p line - local (fmap $ \s -> s { tsVars = zip vars (map (SomeVarValue mempty . const) capture) ++ tsVars s }) inner + local (fmap $ \s -> s { tsVars = zip vars (map (SomeVarValue mempty . const . const) capture) ++ tsVars s }) inner Nothing -> exprFailed (T.pack "expect") (SourceLine sline) (Just $ procName p) expr |