summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2024-08-03 21:36:47 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2024-08-06 21:59:09 +0200
commit7f35daac6a9b0c4e286f5b4bfc7010f074b52b57 (patch)
treeffc64a544b7c775bbb23fc526fa5c32626fbb6df
parent06f36e701ad8a036229aa7cbadf4cd47527cdcc2 (diff)
Test block expression type and statement
-rw-r--r--src/Run.hs4
-rw-r--r--src/Test.hs9
2 files changed, 13 insertions, 0 deletions
diff --git a/src/Run.hs b/src/Run.hs
index a40641b..a69ba75 100644
--- a/src/Run.hs
+++ b/src/Run.hs
@@ -121,6 +121,10 @@ evalSteps = mapM_ $ \case
forM_ value $ \i -> do
withVar name i $ evalSteps inner
+ ExprStatement expr -> do
+ TestBlock steps <- eval expr
+ evalSteps steps
+
Subnet name@(TypedVarName vname) parentExpr inner -> do
parent <- eval parentExpr
withSubnet parent (Just name) $ \net -> do
diff --git a/src/Test.hs b/src/Test.hs
index 7f698a2..a54bbbd 100644
--- a/src/Test.hs
+++ b/src/Test.hs
@@ -2,6 +2,7 @@ module Test (
Module(..),
Test(..),
TestStep(..),
+ TestBlock(..),
SourceLine(..),
MonadEval(..),
@@ -41,8 +42,11 @@ data Test = Test
, testSteps :: [TestStep]
}
+newtype TestBlock = TestBlock [ TestStep ]
+
data TestStep = forall a. ExprType a => Let SourceLine (TypedVarName a) (Expr a) [TestStep]
| forall a. ExprType a => For SourceLine (TypedVarName a) (Expr [a]) [TestStep]
+ | ExprStatement (Expr TestBlock)
| Subnet (TypedVarName Network) (Expr Network) [TestStep]
| DeclNode (TypedVarName Node) (Expr Network) [TestStep]
| Spawn (TypedVarName Process) (Either (Expr Network) (Expr Node)) [TestStep]
@@ -126,6 +130,11 @@ instance ExprType a => ExprType [a] where
exprListUnpacker _ = Just $ ExprListUnpacker id (const Proxy)
+instance ExprType TestBlock where
+ textExprType _ = "test block"
+ textExprValue _ = "<test block>"
+ emptyVarValue = TestBlock []
+
data SomeVarValue = forall a. ExprType a => SomeVarValue a
data RecordSelector a = forall b. ExprType b => RecordSelector (a -> b)