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

View File

@ -582,6 +582,11 @@ testIf = TestList
p = undefined p = undefined
over ops = ops {genExpression = override1 dollar, genProcess = override1 at, genStop = override2 caret, genSpec = override2 hash} 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: ---Returns the list of tests:
tests :: Test tests :: Test
tests = TestList tests = TestList
@ -601,4 +606,5 @@ tests = TestList
,testReplicator ,testReplicator
,testStop ,testStop
,testWait ,testWait
,testWhile
] ]