Added tests for the AllocMobile item in the C and C++ backends
This commit is contained in:
parent
dd86b240b5
commit
48c1bea724
|
@ -72,6 +72,7 @@ data GenOps = GenOps {
|
|||
genActual :: GenOps -> A.Actual -> CGen (),
|
||||
-- | Generates the list of actual parameters to a function\/proc.
|
||||
genActuals :: GenOps -> [A.Actual] -> CGen (),
|
||||
genAllocMobile :: GenOps -> Meta -> A.Type -> Maybe A.Expression -> CGen(),
|
||||
genAlt :: GenOps -> Bool -> A.Structured -> CGen (),
|
||||
-- | Generates the given array element expressions as a flattened (one-dimensional) list of literals
|
||||
genArrayLiteralElems :: GenOps -> [A.ArrayElem] -> CGen (),
|
||||
|
@ -869,6 +870,8 @@ cgenExpression ops (A.IntrinsicFunctionCall m s es) = call genIntrinsicFunction
|
|||
--cgenExpression ops (A.BytesInExpr m e)
|
||||
cgenExpression ops (A.BytesInType m t) = call genBytesIn ops t (Left False)
|
||||
--cgenExpression ops (A.OffsetOf m t n)
|
||||
--cgenExpression ops (A.ExprConstr {})
|
||||
cgenExpression ops (A.AllocMobile m t me) = call genAllocMobile ops m t me
|
||||
cgenExpression ops t = call genMissing ops $ "genExpression " ++ show t
|
||||
|
||||
cgenSizeSuffix :: GenOps -> String -> CGen ()
|
||||
|
|
|
@ -1050,6 +1050,17 @@ testBytesIn = TestList
|
|||
where
|
||||
over ops = ops {genVariable = override1 dollar, genSizeSuffix = (\_ n -> tell["(@",n,")"])}
|
||||
|
||||
testMobile :: Test
|
||||
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)
|
||||
]
|
||||
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}
|
||||
|
||||
---Returns the list of tests:
|
||||
tests :: Test
|
||||
tests = TestList
|
||||
|
@ -1068,6 +1079,7 @@ tests = TestList
|
|||
,testGetTime
|
||||
,testIf
|
||||
,testInput
|
||||
,testMobile
|
||||
,testOutput
|
||||
,testOverArray
|
||||
,testReplicator
|
||||
|
|
Loading…
Reference in New Issue
Block a user