From 00da3541b7bf1b01de543db8283e9fd88634a903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 9 Jun 2022 21:56:59 +0200 Subject: Guard command --- src/Test.hs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/Test.hs') 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 -- cgit v1.2.3