From 63730b5aff2d1545672bd8e1ea5bc358cf673884 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 27 Feb 2008 18:56:09 +0000 Subject: [PATCH] Adjusted the tests for record definitions in the C/C++ backends to use the new function in the dictionary for them --- backends/GenerateCTest.hs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/backends/GenerateCTest.hs b/backends/GenerateCTest.hs index f54e3b9..7e568b0 100644 --- a/backends/GenerateCTest.hs +++ b/backends/GenerateCTest.hs @@ -552,6 +552,28 @@ testDeclareInitFree = TestLabel "testDeclareInitFree" $ TestList testAllSameInit :: Int -> (String,String) -> A.Type -> A.Expression -> Test testAllSameInit n e t init = testAllInit n e e t (Just init) +testRecord :: Test +testRecord = TestList + [ + --Record types: + testAllSame 400 ("typedef struct{#ATION_True}foo;","") foo False [(bar,A.Int)] + ,testAllSame 401 ("typedef struct{#ATION_True#ATION_True} occam_struct_packed foo;","") foo True [(bar,A.Int),(bar,A.Int)] + ,testAllSame 402 ("typedef struct{#ATION_True}foo;","") foo False [(bar,A.Array [A.Dimension 6, A.Dimension 7] A.Int)] + ] + where + testAll :: Int -> (String,String) -> (String,String) -> A.Name -> Bool -> [(A.Name, A.Type)] -> Test + testAll a b c0 c1 c2 d = testAllS a b c0 c1 c2 d (return ()) over + + testAllS :: Int -> (String,String) -> (String,String) -> A.Name -> Bool -> [(A.Name, A.Type)] -> State CompState () -> (GenOps -> GenOps) -> Test + testAllS n (eCI,eCR) (eCPPI,eCPPR) rn rb rts st overFunc + = testBothS ("testRecord " ++ show n) eCI eCPPI (local overFunc (tcall genRecordTypeSpec rn rb rts)) st + testAllSame n e s0 s1 s2 = testAll n e e s0 s1 s2 + over ops = ops {genDeclaration = override2 (tell . (\x -> ["#ATION_",show x])) + ,declareInit = (override4 (Just $ tell ["#INIT"])), declareFree = override3 (Just $ tell ["#FREE"]) + ,genType = (\x -> tell ["$(",show x,")"]) + ,genVariable = override1 at + } + testSpec :: Test testSpec = TestList [ @@ -569,11 +591,6 @@ testSpec = TestList ,testBothFail "testAllSame 300" (tcall introduceSpec $ A.Specification emptyMeta foo $ A.Place emptyMeta (A.True emptyMeta)) ,testAllSame 350 ("","") $ A.Protocol emptyMeta undefined - --Record types: - ,testAllSame 400 ("typedef struct{#ATION_True}foo;","") $ A.RecordType emptyMeta False [(bar,A.Int)] - ,testAllSame 401 ("typedef struct{#ATION_True#ATION_True} occam_struct_packed foo;","") $ A.RecordType emptyMeta True [(bar,A.Int),(bar,A.Int)] - ,testAll 402 ("typedef struct{#ATION_True}foo;","") ("typedef struct{#ATION_True}foo;","")$ A.RecordType emptyMeta False [(bar,A.Array [A.Dimension 6, A.Dimension 7] A.Int)] - --IsChannelArray: ,testAll 500 ("$(" ++ show chanInt ++ ")*foo[]={@,@};const int foo_sizes[]={2};","")