From 185f68e96d06c1c08dece54eefbfc256d14288a1 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 20 Mar 2008 16:34:44 +0000 Subject: [PATCH] Adjusted the tests for the annotateListLiteralTypes pass --- frontends/RainTypesTest.hs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontends/RainTypesTest.hs b/frontends/RainTypesTest.hs index 887f03d..68533ed 100644 --- a/frontends/RainTypesTest.hs +++ b/frontends/RainTypesTest.hs @@ -110,7 +110,8 @@ annotateListLiteralTest = TestList ,testList 3 A.Int64 [intLiteral 3, intLiteral 5, int64Literal 2, intLiteral 2] -- TODO test with variables (and implicit upcasting) - + + -- TODO test the type for lists of lists -- TODO test ranges with variables too ,testRange 1000 A.Int (intLiteral 0) (intLiteral 1) ,testRange 1001 A.Int64 (intLiteral 0) (int64Literal 1) @@ -124,13 +125,19 @@ annotateListLiteralTest = TestList where testList :: Int -> A.Type -> [A.Expression] -> Test testList n t es = TestCase $ testPass ("annotateListLiteralTest: " ++ - show n) (mLiteral (A.List t) $ mListLiteral es) + show n) (mLiteral (A.List t) $ mListLiteral $ map (maybeConvert t) es) (annotateListLiteralTypes $ A.Literal emptyMeta A.Any $ A.ListLiteral emptyMeta es) (return ()) + maybeConvert :: A.Type -> A.Expression -> A.Expression + maybeConvert t lit@(A.Literal _ lt _) + | t == lt = lit + | otherwise = A.Conversion emptyMeta A.DefaultConversion t lit + testRange :: Int -> A.Type -> A.Expression -> A.Expression -> Test testRange n t b e = TestCase $ testPass ("annotateListLiteralTest: " - ++ show n) (mExprConstr $ mRangeConstr t b e) + ++ show n) (mExprConstr $ + mRangeConstr (A.List t) (maybeConvert t b) (maybeConvert t e)) (annotateListLiteralTypes $ A.ExprConstr emptyMeta $ A.RangeConstr emptyMeta A.Any b e) (return ())