Added a test for genWait in the C and C++ backends

This commit is contained in:
Neil Brown 2007-10-04 14:55:03 +00:00
parent 1f8a5555ac
commit 986b6d956a
2 changed files with 15 additions and 4 deletions

View File

@ -158,6 +158,7 @@ data GenOps = GenOps {
genVariableAM :: GenOps -> A.Variable -> A.AbbrevMode -> CGen (),
-- | Generates a variable, with no indexing checks anywhere
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 (),
genWhile :: GenOps -> A.Expression -> A.Process -> CGen (),
getScalarType :: GenOps -> A.Type -> Maybe String,
@ -1562,9 +1563,9 @@ cgenTimerRead ops c v
cgenTimerWait :: GenOps -> A.Expression -> CGen ()
cgenTimerWait ops e
= do tell ["ProcTimeAfter ("]
= do tell ["ProcTimeAfter("]
call genExpression ops e
tell [");\n"]
tell [");"]
cgenGetTime :: GenOps -> Meta -> A.Variable -> CGen ()
cgenGetTime ops m v
@ -1575,9 +1576,9 @@ cgenGetTime ops m v
cgenWait :: GenOps -> A.WaitMode -> A.Expression -> CGen ()
cgenWait ops A.WaitUntil e = call genTimerWait ops e
cgenWait ops A.WaitFor e
= do tell ["ProcAfter ("]
= do tell ["ProcAfter("]
call genExpression ops e
tell [");\n"]
tell [");"]
--}}}
--{{{ output

View File

@ -557,6 +557,15 @@ testGetTime = testBoth "testGetTime 0" "ProcTime(&@);" "csp::CurrentTime(&@);" (
where
over ops = ops {genVariable = override1 at}
testWait :: Test
testWait = TestList
[
testBoth "testWait 0" "ProcTimeAfter($);" "csp::SleepUntil($);" ((tcall2 genWait A.WaitUntil undefined) . over)
,testBoth "testWait 1" "ProcAfter($);" "csp::SleepFor($);" ((tcall2 genWait A.WaitFor undefined) . over)
]
where
over ops = ops {genExpression = override1 dollar}
testIf :: Test
testIf = TestList
[
@ -591,4 +600,5 @@ tests = TestList
,testOverArray
,testReplicator
,testStop
,testWait
]