diff --git a/backends/BackendPassesTest.hs b/backends/BackendPassesTest.hs index a399921..079e453 100644 --- a/backends/BackendPassesTest.hs +++ b/backends/BackendPassesTest.hs @@ -26,11 +26,15 @@ import Test.HUnit hiding (State) import qualified AST as A import BackendPasses +import Metadata import Pattern import TagAST import TestUtils import TreeUtils +m :: Meta +m = emptyMeta + -- | Test WaitUntil guard (should be unchanged) testTransformWaitFor0 :: Test testTransformWaitFor0 = TestCase $ testPass "testTransformWaitFor0" orig (transformWaitFor orig) (return ()) diff --git a/checks/ArrayUsageCheckTest.hs b/checks/ArrayUsageCheckTest.hs index 9ec5a1a..33aac6f 100644 --- a/checks/ArrayUsageCheckTest.hs +++ b/checks/ArrayUsageCheckTest.hs @@ -38,7 +38,7 @@ import Omega import ShowCode import TestFramework import TestHarness -import TestUtils hiding (m) +import TestUtils import UsageCheckUtils hiding (Var) import Utils diff --git a/checks/RainUsageCheckTest.hs b/checks/RainUsageCheckTest.hs index 3c4d163..de5c176 100644 --- a/checks/RainUsageCheckTest.hs +++ b/checks/RainUsageCheckTest.hs @@ -50,6 +50,8 @@ tvB = Var $ vB tvC = Var $ vC tvD = Var $ vD tvL = Var $ vL + +m = emptyMeta --These are all shorthand for some useful "building block" processes --The syntax is roughly: _eq_ diff --git a/common/TestUtils.hs b/common/TestUtils.hs index 2e947fe..8e0cc72 100644 --- a/common/TestUtils.hs +++ b/common/TestUtils.hs @@ -50,7 +50,7 @@ import Test.QuickCheck import qualified AST as A import CompState import Errors -import Metadata (Meta,emptyMeta) +import Metadata (emptyMeta) import Pass import Pattern import PrettyShow @@ -116,12 +116,6 @@ timeTask label (low,med,high) test level let mean = average times return (label, mean, Just $ average (map (\x -> (x - mean) * (x - mean)) times)) - - --- | An abbreviation for using 'emptyMeta'. TODO: This should really be removed (and all uses of it replaced with 'emptyMeta') for clarity. -m :: Meta -m = emptyMeta - -- | Creates a 'A.Name' object with the given 'String' as 'A.nameName', and 'A.nameType' as 'A.VariableName'. simpleName :: String -> A.Name simpleName s = A.Name { A.nameName = s , A.nameMeta = emptyMeta , A.nameType = A.VariableName } @@ -423,29 +417,29 @@ data ExprHelper = | EHTrue buildExprPattern :: ExprHelper -> Pattern -buildExprPattern = (stopCaringPattern m) . mkPattern . buildExpr +buildExprPattern = (stopCaringPattern emptyMeta) . mkPattern . buildExpr buildExpr :: ExprHelper -> A.Expression -buildExpr (Dy lhs op rhs) = A.Dyadic m op (buildExpr lhs) (buildExpr rhs) -buildExpr (Mon op rhs) = A.Monadic m op (buildExpr rhs) -buildExpr (Cast ty rhs) = A.Conversion m A.DefaultConversion ty (buildExpr rhs) -buildExpr (Var n) = A.ExprVariable m $ variable n -buildExpr (DirVar dir n) = A.ExprVariable m $ (A.DirectedVariable m dir $ variable n) +buildExpr (Dy lhs op rhs) = A.Dyadic emptyMeta op (buildExpr lhs) (buildExpr rhs) +buildExpr (Mon op rhs) = A.Monadic emptyMeta op (buildExpr rhs) +buildExpr (Cast ty rhs) = A.Conversion emptyMeta A.DefaultConversion ty (buildExpr rhs) +buildExpr (Var n) = A.ExprVariable emptyMeta $ variable n +buildExpr (DirVar dir n) = A.ExprVariable emptyMeta $ (A.DirectedVariable emptyMeta dir $ variable n) buildExpr (Lit e) = e -buildExpr EHTrue = A.True m +buildExpr EHTrue = A.True emptyMeta -- | A simple definition of a variable simpleDef :: String -> A.SpecType -> A.NameDef -simpleDef n sp = A.NameDef {A.ndMeta = m, A.ndName = n, A.ndOrigName = n, A.ndNameType = A.VariableName, +simpleDef n sp = A.NameDef {A.ndMeta = emptyMeta, A.ndName = n, A.ndOrigName = n, A.ndNameType = A.VariableName, A.ndType = sp, A.ndAbbrevMode = A.Original, A.ndPlacement = A.Unplaced} -- | A simple definition of a declared variable simpleDefDecl :: String -> A.Type -> A.NameDef -simpleDefDecl n t = simpleDef n (A.Declaration m t Nothing) +simpleDefDecl n t = simpleDef n (A.Declaration emptyMeta t Nothing) -- | A simple definition of a declared variable simpleDefDeclInit :: String -> A.Type -> Maybe A.Expression -> A.NameDef -simpleDefDeclInit n t init = simpleDef n (A.Declaration m t init) +simpleDefDeclInit n t init = simpleDef n (A.Declaration emptyMeta t init) -- | A pattern that will match simpleDef, with a different abbreviation mode simpleDefPattern :: String -> A.AbbrevMode -> Pattern -> Pattern diff --git a/frontends/ParseRainTest.hs b/frontends/ParseRainTest.hs index 43e11af..97dbe2d 100644 --- a/frontends/ParseRainTest.hs +++ b/frontends/ParseRainTest.hs @@ -63,6 +63,9 @@ fail x = ExpFail x pat :: Data a => a -> Pattern pat = (stopCaringPattern emptyMeta) . mkPattern +m :: Meta +m = emptyMeta + -- | Runs a parse test, given a tuple of: (source text, parser function, assertion) -- There will be success if the parser succeeds, and the output succeeds against the given assertion. testParsePass :: Show a => (String, RP.RainParser a , (a -> Assertion)) -> Assertion diff --git a/frontends/RainPassesTest.hs b/frontends/RainPassesTest.hs index c256717..f7cefce 100644 --- a/frontends/RainPassesTest.hs +++ b/frontends/RainPassesTest.hs @@ -38,6 +38,7 @@ import Test.HUnit hiding (State) import qualified AST as A import CompState import Errors +import Metadata import Pattern import RainPasses import RainTypes @@ -45,6 +46,9 @@ import TagAST import TestUtils import TreeUtils +m :: Meta +m = emptyMeta + -- | A helper function that returns a simple A.Structured A.Process item (A.Only m $ A.Skip m). skipP :: A.Structured A.Process skipP = A.Only m (A.Skip m) diff --git a/frontends/RainTypesTest.hs b/frontends/RainTypesTest.hs index 12ea33d..36de955 100644 --- a/frontends/RainTypesTest.hs +++ b/frontends/RainTypesTest.hs @@ -28,6 +28,7 @@ import Test.HUnit hiding (State) import qualified AST as A import CompState import Errors +import Metadata import Pass import Pattern import RainTypes @@ -37,6 +38,9 @@ import TreeUtils import Types import Utils +m :: Meta +m = emptyMeta + -- | Tests that constants in expressions are folded properly. TODO these tests could do with a lot of expanding. -- It may even be easiest to use QuickCheck for the testing. constantFoldTest :: Test diff --git a/transformations/PassTest.hs b/transformations/PassTest.hs index c866cac..ac3b31b 100644 --- a/transformations/PassTest.hs +++ b/transformations/PassTest.hs @@ -34,6 +34,9 @@ import TagAST import TestUtils import TreeUtils +m :: Meta +m = emptyMeta + -- | A handy typed version of Nothing for use with A.Declaration noInit :: Maybe A.Expression noInit = Nothing