Added tests for ClearMobile in the C and C++ backends

This commit is contained in:
Neil Brown 2007-10-24 20:52:39 +00:00
parent 1f604781f5
commit dfee567ffc
2 changed files with 5 additions and 1 deletions

View File

@ -94,6 +94,7 @@ data GenOps = GenOps {
-- | Generates a case statement over the given expression with the structured as the body.
genCase :: GenOps -> Meta -> A.Expression -> A.Structured -> CGen (),
genCheckedConversion :: GenOps -> Meta -> A.Type -> A.Type -> CGen () -> CGen (),
genClearMobile :: GenOps -> Meta -> A.Variable -> CGen (),
genConversion :: GenOps -> Meta -> A.ConversionMode -> A.Type -> A.Expression -> CGen (),
genConversionSymbol :: GenOps -> A.Type -> A.Type -> A.ConversionMode -> CGen (),
genDecl :: GenOps -> A.AbbrevMode -> A.Type -> A.Name -> CGen (),

View File

@ -1055,11 +1055,14 @@ testMobile = TestList
[
testBoth "testMobile 0" "malloc(#(Int Left False))" "new Int" ((tcall3 genAllocMobile emptyMeta (A.Mobile A.Int) Nothing) . over)
,TestCase $ assertGen "testMobile 1/C++" "new Int($)" $ (evalStateT (runErrorT (execWriterT $ call genAllocMobile (over cppgenOps) emptyMeta (A.Mobile A.Int) (Just undefined))) emptyState)
,testBoth "testMobile 100" "if(@!=NULL){free(@);@=NULL;}" "if(@!=NULL){delete @;@=NULL;}"
((tcall2 genClearMobile emptyMeta undefined) . over)
]
where
showBytesInParams _ t (Right _) = tell ["#(" ++ show t ++ " Right)"]
showBytesInParams _ t v = tell ["#(" ++ show t ++ " " ++ show v ++ ")"]
over ops = ops {genBytesIn = showBytesInParams, genType = (\_ t -> tell [show t]), genExpression = override1 dollar}
over ops = ops {genBytesIn = showBytesInParams, genType = (\_ t -> tell [show t]), genExpression = override1 dollar, genVariable = override1 at}
---Returns the list of tests:
tests :: Test