diff --git a/RainParseTest.hs b/RainParseTest.hs index 88b7944..c22c33a 100644 --- a/RainParseTest.hs +++ b/RainParseTest.hs @@ -182,8 +182,8 @@ testEach :: [ParseTest A.Process] testEach = [ pass ("seqeach (c : \"1\") c = 7;", RP.statement, - assertEqual "Each Test 0" $ A.Seq m $ A.Rep m (A.ForEach m (simpleName "c") (makeLiteralString "1")) $ - A.OnlyP m $ (makeAssign (variable "c") (A.Literal m A.Int (A.IntLiteral m "7"))) ) + assertPatternMatch "Each Test 0" (stopCaringPattern m $ mkPattern $ A.Seq m $ A.Rep m (A.ForEach m (simpleName "c") (makeLiteralString "1")) $ + A.OnlyP m $ (makeAssign (variable "c") (A.Literal m A.Int (A.IntLiteral m "7"))) )) ,pass ("pareach (c : \"345\") {c = 1; c = 2;}", RP.statement, assertEqual "Each Test 1" $ A.Par m A.PlainPar $ A.Rep m (A.ForEach m (simpleName "c") (makeLiteralString "345")) $ A.OnlyP m $ makeSeq[(makeAssign (variable "c") (A.Literal m A.Int (A.IntLiteral m "1"))),(makeAssign (variable "c") (A.Literal m A.Int (A.IntLiteral m "2")))] ) diff --git a/TestUtil.hs b/TestUtil.hs index 0eb30c8..23d0f07 100644 --- a/TestUtil.hs +++ b/TestUtil.hs @@ -56,7 +56,7 @@ intLiteral :: Int -> A.Expression intLiteral n = A.Literal m A.Int $ A.IntLiteral m (show n) intLiteralPattern :: Int -> Pattern -intLiteralPattern n = tag3 A.Literal DontCare A.Int (tag2 A.IntLiteral DontCare (show n)) +intLiteralPattern = (stopCaringPattern m) . mkPattern . intLiteral makeNamesWR :: ([String],[String]) -> ([A.Variable],[A.Variable]) makeNamesWR (x,y) = (map variable x,map variable y) @@ -85,6 +85,8 @@ makeLiteralString str = A.Literal m (A.Array [A.Dimension (length str)] A.Byte) makeLiteralChar :: Char -> A.ArrayElem makeLiteralChar c = A.ArrayElemExpr $ A.Literal m A.Byte (A.ByteLiteral m [c] {-(show (fromEnum c))-}) +makeLiteralStringPattern :: String -> Pattern +makeLiteralStringPattern = (stopCaringPattern m) . mkPattern . makeLiteralString assertCompareCustom :: (Show a) => String -> (a -> a -> Bool) -> a -> a -> Assertion assertCompareCustom preface cmp expected actual =