Rain: added a test for recording and resolving process parameters
This commit is contained in:
parent
a897712033
commit
412a746e25
|
@ -187,6 +187,31 @@ testUnique3 = testPassWithItemsStateCheck "testUnique3" exp (uniquifyAndResolveV
|
|||
check (items,state) = assertVarDef "testUnique3: Variable was not recorded" state "foo"
|
||||
(tag7 A.NameDef DontCare "foo" "foo" A.ProcName (A.Proc m A.PlainSpec [] $ A.Skip m) A.Original A.Unplaced)
|
||||
|
||||
-- | Tests that parameters are uniquified and resolved:
|
||||
testUnique4 :: Test
|
||||
testUnique4 = testPassWithItemsStateCheck "testUnique4" exp (uniquifyAndResolveVars orig) (return ()) check
|
||||
where
|
||||
orig = A.Spec m (A.Specification m (procName "foo") $ A.Proc m A.PlainSpec [A.Formal A.ValAbbrev A.Byte $ simpleName "c"] $ A.Skip m) (A.OnlyP m $
|
||||
A.ProcCall m (procName "foo") [A.ActualExpression A.Byte $ exprVariable "c"])
|
||||
exp = tag3 A.Spec DontCare
|
||||
(tag3 A.Specification DontCare (procNamePattern "foo") $ tag4 A.Proc DontCare A.PlainSpec
|
||||
[tag3 A.Formal A.ValAbbrev A.Byte newc] $ tag1 A.Skip DontCare)
|
||||
(tag2 A.OnlyP DontCare $ tag3 A.ProcCall DontCare (procNamePattern "foo")
|
||||
[tag2 A.ActualExpression A.Byte $ tag2 A.ExprVariable DontCare $ tag2 A.Variable DontCare newc]
|
||||
)
|
||||
|
||||
newc = Named "newc" DontCare
|
||||
check (items,state)
|
||||
= do newcName <- castAssertADI (Map.lookup "newc" items)
|
||||
assertNotEqual "testUnique4: Variable was not made unique" "c" (A.nameName newcName)
|
||||
assertVarDef "testUnique4: Variable was not recorded" state (A.nameName newcName)
|
||||
(tag7 A.NameDef DontCare (A.nameName newcName) "c" A.VariableName (A.Declaration m A.Byte) A.Original A.Unplaced)
|
||||
assertVarDef "testUnique4: Variable was not recorded" state "foo"
|
||||
(tag7 A.NameDef DontCare "foo" "foo" A.ProcName (tag4 A.Proc DontCare A.PlainSpec [tag3 A.Formal A.ValAbbrev A.Byte newcName] $
|
||||
tag1 A.Skip DontCare) A.Original A.Unplaced)
|
||||
|
||||
|
||||
|
||||
|
||||
-- | checks that c's type is recorded in: ***each (c : "hello") {}
|
||||
testRecordInfNames0 :: Test
|
||||
|
@ -271,6 +296,7 @@ tests = TestList
|
|||
,testUnique1
|
||||
,testUnique2
|
||||
,testUnique3
|
||||
,testUnique4
|
||||
,testRecordInfNames0
|
||||
,testRecordInfNames1
|
||||
,testRecordInfNames2
|
||||
|
|
|
@ -43,7 +43,10 @@ procName :: String -> A.Name
|
|||
procName s = A.Name { A.nameName = s , A.nameMeta = emptyMeta , A.nameType = A.ProcName }
|
||||
|
||||
simpleNamePattern :: String -> Pattern
|
||||
simpleNamePattern s = tag3 A.Name DontCare DontCare s
|
||||
simpleNamePattern s = tag3 A.Name DontCare A.VariableName s
|
||||
|
||||
procNamePattern :: String -> Pattern
|
||||
procNamePattern s = tag3 A.Name DontCare A.ProcName s
|
||||
|
||||
variable :: String -> A.Variable
|
||||
variable e = A.Variable m $ simpleName e
|
||||
|
|
Loading…
Reference in New Issue
Block a user