diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 4 | ||||
-rw-r--r-- | src/Parser.hs | 6 | ||||
-rw-r--r-- | src/Test.hs | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs index fda0bb9..494b028 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -317,6 +317,10 @@ evalSteps = mapM_ $ \case value <- eval expr withVar name value $ evalSteps inner + DeclNode name@(TypedVarName vname) inner -> do + createNode name $ \node -> do + withVar vname node $ evalSteps inner + Spawn (TypedVarName vname@(VarName tname)) nname inner -> do either createNode ((>>=) . eval) nname $ \node -> do let pname = ProcName tname diff --git a/src/Parser.hs b/src/Parser.hs index 7773bae..a33b429 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -476,6 +476,11 @@ testLocal = do indent <- L.indentGuard scn GT ref localState $ testBlock indent +testNode :: TestParser [TestStep] +testNode = command "node" $ DeclNode + <$> param "" + <*> innerBlock + testSpawn :: TestParser [TestStep] testSpawn = command "spawn" $ Spawn <$> param "as" @@ -528,6 +533,7 @@ testStep :: TestParser [TestStep] testStep = choice [ letStatement , testLocal + , testNode , testSpawn , testSend , testExpect diff --git a/src/Test.hs b/src/Test.hs index 5a45930..6b04fac 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -33,6 +33,7 @@ data Test = Test } data TestStep = forall a. ExprType a => Let SourceLine VarName (Expr a) [TestStep] + | DeclNode (TypedVarName Node) [TestStep] | Spawn (TypedVarName Process) (Either (TypedVarName Node) (Expr Node)) [TestStep] | Send (Expr Process) (Expr Text) | Expect SourceLine (Expr Process) (Expr Regex) [TypedVarName Text] [TestStep] |