From 54ba4c3315bd1aec6f867adf6f6b3f66df982b43 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 23 Aug 2007 21:20:55 +0000 Subject: [PATCH] Rain: added tests for parsing process calls --- RainParseTest.hs | 17 +++++++++++++++++ TestUtil.hs | 3 +++ 2 files changed, 20 insertions(+) diff --git a/RainParseTest.hs b/RainParseTest.hs index f811f11..de141ba 100644 --- a/RainParseTest.hs +++ b/RainParseTest.hs @@ -464,6 +464,22 @@ testComm = ,fail ("c ? x ? y;",RP.statement) ,fail ("c ? x , y;",RP.statement) ] + +testRun :: [ParseTest A.Process] +testRun = + [ + pass ("run foo();",RP.statement,assertPatternMatch "testRun 1" $ tag3 A.ProcCall DontCare (procNamePattern "foo") ([] :: [A.Actual])) + ,pass ("run foo(c);",RP.statement,assertPatternMatch "testRun 2" $ tag3 A.ProcCall DontCare (procNamePattern "foo") + [tag3 A.ActualVariable A.Original A.Any (variablePattern "c")]) + ,pass ("run foo(c,0+x);",RP.statement,assertPatternMatch "testRun 3" $ tag3 A.ProcCall DontCare (procNamePattern "foo") + [tag3 A.ActualVariable A.Original A.Any (variablePattern "c"),tag2 A.ActualExpression A.Any $ tag4 A.Dyadic DontCare A.Plus (intLiteralPattern 0) (exprVariablePattern "x")]) + ,fail ("run",RP.statement) + ,fail ("run;",RP.statement) + ,fail ("run ();",RP.statement) + ,fail ("run foo()",RP.statement) + ,fail ("run foo(,);",RP.statement) + + ] --Returns the list of tests: tests :: Test @@ -480,6 +496,7 @@ tests = TestList parseTests testAssign, parseTests testDataType, parseTests testComm, + parseTests testRun, parseTests testDecl, parseTests testTopLevelDecl ] diff --git a/TestUtil.hs b/TestUtil.hs index 5e47122..8622674 100644 --- a/TestUtil.hs +++ b/TestUtil.hs @@ -61,6 +61,9 @@ variablePattern e = tag2 A.Variable DontCare (simpleNamePattern e) exprVariable :: String -> A.Expression exprVariable e = A.ExprVariable m $ variable e +exprVariablePattern :: String -> Pattern +exprVariablePattern e = tag2 A.ExprVariable DontCare $ variablePattern e + intLiteral :: Integer -> A.Expression intLiteral n = A.Literal m A.Int $ A.IntLiteral m (show n)