summaryrefslogtreecommitdiff
path: root/src/Test.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-06-09 21:56:59 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-06-09 21:56:59 +0200
commit00da3541b7bf1b01de543db8283e9fd88634a903 (patch)
treef36e6f9931c055706b2228322ffce0b7e00108f8 /src/Test.hs
parent62251c102c57d4c12da6923dc0ea5747cfb3ef0c (diff)
Guard command
Diffstat (limited to 'src/Test.hs')
-rw-r--r--src/Test.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Test.hs b/src/Test.hs
index 404d965..e21eaee 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -31,6 +31,7 @@ data Test = Test
data TestStep = Spawn ProcName NodeName
| Send ProcName (Expr Text)
| Expect SourceLine ProcName (Expr Regex) [VarName]
+ | Guard SourceLine (Expr Bool)
| Wait
newtype SourceLine = SourceLine Text
@@ -64,6 +65,7 @@ data Expr a where
StringLit :: Text -> Expr Text
Concat :: [Expr Text] -> Expr Text
Regex :: [Expr Text] -> Expr Regex
+ BinOp :: (b -> c -> a) -> Expr b -> Expr c -> Expr a
eval :: MonadEval m => Expr a -> m a
eval (StringVar var) = lookupStringVar var
@@ -76,3 +78,4 @@ eval (Regex xs) = do
case compile defaultCompOpt defaultExecOpt $ T.concat $ concat [[T.singleton '^'], parts, [T.singleton '$']] of
Left err -> fail err
Right re -> return re
+eval (BinOp f x y) = f <$> eval x <*> eval y