Fixed some of the test modules to work with the new array literals and constructors

This commit is contained in:
Neil Brown 2009-02-03 11:19:21 +00:00
parent 502c61b01e
commit 6afbb80e9f
3 changed files with 14 additions and 16 deletions

View File

@ -304,8 +304,8 @@ qcTestDeclareSizes =
valSize ds = A.IsExpr emptyMeta A.ValAbbrev (A.Array [dimension $ length ds] A.Int) $ makeSizesLiteral ds valSize ds = A.IsExpr emptyMeta A.ValAbbrev (A.Array [dimension $ length ds] A.Int) $ makeSizesLiteral ds
makeSizesLiteral :: [A.Expression] -> A.Expression makeSizesLiteral :: [A.Expression] -> A.Expression
makeSizesLiteral xs = A.Literal emptyMeta (A.Array [dimension $ length xs] A.Int) $ A.ArrayLiteral emptyMeta $ makeSizesLiteral xs = A.Literal emptyMeta (A.Array [dimension $ length xs] A.Int) $
map A.ArrayElemExpr xs A.ArrayListLiteral emptyMeta $ A.Several emptyMeta $ map (A.Only emptyMeta) xs
checkFooSizes :: TestMonad m r => A.SpecType -> CompState -> m () checkFooSizes :: TestMonad m r => A.SpecType -> CompState -> m ()
checkFooSizes sp = checkName "foo_sizes" sp A.ValAbbrev checkFooSizes sp = checkName "foo_sizes" sp A.ValAbbrev

View File

@ -306,9 +306,12 @@ testStop =
testArraySizes :: Test testArraySizes :: Test
testArraySizes = TestList testArraySizes = TestList
[ [
testBothSame "genArrayLiteralElems 0" "$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined]) testBothSame "genArrayLiteralElems 0" "$" $ unfolded (tcall genArrayLiteralElems $
,testBothSame "genArrayLiteralElems 1" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined, A.ArrayElemExpr undefined]) A.Only emptyMeta undefined)
,testBothSame "genArrayLiteralElems 2" "$,$,$" $ unfolded (tcall genArrayLiteralElems [A.ArrayElemExpr undefined, A.ArrayElemArray [A.ArrayElemExpr undefined, A.ArrayElemExpr undefined]]) ,testBothSame "genArrayLiteralElems 1" "$,$,$" $ unfolded (tcall genArrayLiteralElems $
A.Several emptyMeta [A.Only emptyMeta undefined, A.Only emptyMeta undefined, A.Only emptyMeta undefined])
,testBothSame "genArrayLiteralElems 2" "$,$,$" $ unfolded (tcall genArrayLiteralElems $
A.Several emptyMeta [A.Only emptyMeta undefined, A.Several emptyMeta [A.Only emptyMeta undefined, A.Only emptyMeta undefined]])
] ]
where where
unfolded :: Override unfolded :: Override

View File

@ -73,7 +73,7 @@ startState
defineProc "proc2" [("x", A.ValAbbrev, A.Int), ("y", A.Abbrev, A.Int)] defineProc "proc2" [("x", A.ValAbbrev, A.Int), ("y", A.Abbrev, A.Int)]
where where
intsT = A.Array [A.UnknownDimension] A.Int intsT = A.Array [A.UnknownDimension] A.Int
arrayLit = A.ArrayLiteral m [] arrayLit = A.ArrayListLiteral m $ A.Several m []
chanT t = A.Chan (A.ChanAttributes False False) t chanT t = A.Chan (A.ChanAttributes False False) t
chanIntT = chanT A.Int chanIntT = chanT A.Int
countedIntsT = chanT $ A.UserProtocol (simpleName "countedInts") countedIntsT = chanT $ A.UserProtocol (simpleName "countedInts")
@ -144,9 +144,6 @@ testOccamTypes = TestList
, testFail 113 $ A.Dyadic m A.And boolE intE , testFail 113 $ A.Dyadic m A.And boolE intE
, testFail 114 $ A.Dyadic m A.And intE boolE , testFail 114 $ A.Dyadic m A.And intE boolE
, testFail 115 $ A.Dyadic m A.Add twoIntsE twoIntsE , testFail 115 $ A.Dyadic m A.Add twoIntsE twoIntsE
, testOK 116 $ A.Dyadic m A.Concat listE listE
, testFail 117 $ A.Dyadic m A.Concat listE intE
, testFail 118 $ A.Dyadic m A.Concat intE listE
-- Miscellaneous expressions -- Miscellaneous expressions
, testOK 150 $ A.MostPos m A.Int , testOK 150 $ A.MostPos m A.Int
@ -302,7 +299,6 @@ testOccamTypes = TestList
, testFail 1201 $ testRep i $ A.For m realE intE intE , testFail 1201 $ testRep i $ A.For m realE intE intE
, testFail 1202 $ testRep i $ A.For m intE realE intE , testFail 1202 $ testRep i $ A.For m intE realE intE
, testOK 1203 $ testRep i $ A.ForEach m twoIntsE , testOK 1203 $ testRep i $ A.ForEach m twoIntsE
, testOK 1204 $ testRep i $ A.ForEach m listE
, testFail 1205 $ testRep i $ A.ForEach m intE , testFail 1205 $ testRep i $ A.ForEach m intE
, testFail 1206 $ testRep i $ A.For m intE intE realE , testFail 1206 $ testRep i $ A.For m intE intE realE
@ -554,11 +550,12 @@ testOccamTypes = TestList
twoTwoIntsT = A.Array [dimension 2, dimension 2] A.Int twoTwoIntsT = A.Array [dimension 2, dimension 2] A.Int
twoBytesT = A.Array [dimension 2] A.Byte twoBytesT = A.Array [dimension 2] A.Byte
threeIntsT = A.Array [dimension 3] A.Int threeIntsT = A.Array [dimension 3] A.Int
ae = A.ArrayElemExpr intE ae = A.Only m intE
twoInts = A.ArrayLiteral m [ae, ae] twoInts = A.ArrayListLiteral m $ A.Several m [ae, ae]
twoIntsE = A.Literal m twoIntsT twoInts twoIntsE = A.Literal m twoIntsT twoInts
twoTwoInts = A.ArrayLiteral m [A.ArrayElemArray [ae, ae], twoTwoInts = A.ArrayListLiteral m $ A.Several m
A.ArrayElemArray [ae, ae]] [A.Several m [ae, ae],
A.Several m [ae, ae]]
twoTwoIntsE = A.Literal m twoTwoIntsT twoTwoInts twoTwoIntsE = A.Literal m twoTwoIntsT twoTwoInts
myIntT = A.UserDataType (simpleName "MYINT") myIntT = A.UserDataType (simpleName "MYINT")
myTwoIntsT = A.UserDataType (simpleName "MY2INT") myTwoIntsT = A.UserDataType (simpleName "MY2INT")
@ -585,8 +582,6 @@ testOccamTypes = TestList
function1 = simpleName "function1" function1 = simpleName "function1"
function2 = simpleName "function2" function2 = simpleName "function2"
function22 = simpleName "function22" function22 = simpleName "function22"
listT = A.List A.Int
listE = A.Literal m listT (A.ListLiteral m [intE, intE, intE])
i = simpleName "i" i = simpleName "i"
countedIntsC = variable "chanCountedInts" countedIntsC = variable "chanCountedInts"
countedIntsCin = A.DirectedVariable emptyMeta A.DirInput countedIntsC countedIntsCin = A.DirectedVariable emptyMeta A.DirInput countedIntsC