Added a test for genWhile to the C and C++ backends

This commit is contained in:
Neil Brown 2007-10-04 14:58:28 +00:00
parent 986b6d956a
commit 4d2833affb
2 changed files with 10 additions and 3 deletions

View File

@ -160,6 +160,7 @@ data GenOps = GenOps {
genVariableUnchecked :: GenOps -> A.Variable -> CGen (),
-- | Performs a wait for\/until (depending on the 'A.WaitMode') a specified time
genWait :: GenOps -> A.WaitMode -> A.Expression -> CGen (),
-- | Generates a while loop with the given condition and body.
genWhile :: GenOps -> A.Expression -> A.Process -> CGen (),
getScalarType :: GenOps -> A.Type -> Maybe String,
introduceSpec :: GenOps -> A.Specification -> CGen (),
@ -1668,11 +1669,11 @@ cgenCase ops m e s
--{{{ while
cgenWhile :: GenOps -> A.Expression -> A.Process -> CGen ()
cgenWhile ops e p
= do tell ["while ("]
= do tell ["while("]
call genExpression ops e
tell [") {\n"]
tell ["){"]
call genProcess ops p
tell ["}\n"]
tell ["}"]
--}}}
--{{{ par
cgenPar :: GenOps -> A.ParMode -> A.Structured -> CGen ()

View File

@ -582,6 +582,11 @@ testIf = TestList
p = undefined
over ops = ops {genExpression = override1 dollar, genProcess = override1 at, genStop = override2 caret, genSpec = override2 hash}
testWhile :: Test
testWhile = testBothSame "testWhile 0" "while($){@}" ((tcall2 genWhile undefined undefined) . over)
where
over ops = ops {genExpression = override1 dollar, genProcess = override1 at}
---Returns the list of tests:
tests :: Test
tests = TestList
@ -601,4 +606,5 @@ tests = TestList
,testReplicator
,testStop
,testWait
,testWhile
]