diff --git a/Makefile.am b/Makefile.am
index 569e8f2..dad0336 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -182,6 +182,7 @@ tocktest_SOURCES += frontends/RainTypesTest.hs
tocktest_SOURCES += frontends/StructureOccamTest.hs
tocktest_SOURCES += transformations/PassTest.hs
tocktest_SOURCES += transformations/SimplifyAbbrevsTest.hs
+tocktest_SOURCES += transformations/SimplifyTypesTest.hs
pregen_sources = data/AST.hs
pregen_sources += pregen/PregenUtils.hs
diff --git a/TestMain.hs b/TestMain.hs
index f7335c3..afce5ea 100644
--- a/TestMain.hs
+++ b/TestMain.hs
@@ -46,6 +46,8 @@ with this program. If not, see .
--
-- * "SimplifyAbbrevsTest"
--
+-- * "SimplifyTypesTest"
+--
-- * "StructureOccamTest"
--
-- * "UsageCheckTest"
@@ -73,6 +75,7 @@ import qualified PreprocessOccamTest (tests)
import qualified RainPassesTest (tests)
import qualified RainTypesTest (ioTests)
import qualified SimplifyAbbrevsTest (tests)
+import qualified SimplifyTypesTest (tests)
import qualified StructureOccamTest (tests)
import qualified UsageCheckTest (tests)
import TestUtils
@@ -191,6 +194,7 @@ main = do (opts, nonOpts, errs) <- getArgs >>* getOpt RequireOrder options
,noqc RainPassesTest.tests
,noqcButIO RainTypesTest.ioTests
,noqc SimplifyAbbrevsTest.tests
+ ,noqc SimplifyTypesTest.tests
,noqc StructureOccamTest.tests
,noqc UsageCheckTest.tests
]
diff --git a/transformations/SimplifyTypes.hs b/transformations/SimplifyTypes.hs
index 1156837..f0f2c76 100644
--- a/transformations/SimplifyTypes.hs
+++ b/transformations/SimplifyTypes.hs
@@ -17,7 +17,10 @@ with this program. If not, see .
-}
-- | Simplify types in the AST.
-module SimplifyTypes (simplifyTypes) where
+module SimplifyTypes (
+ simplifyTypes
+ , resolveNamedTypes
+ ) where
import Control.Monad.State
diff --git a/transformations/SimplifyTypesTest.hs b/transformations/SimplifyTypesTest.hs
new file mode 100644
index 0000000..4316ded
--- /dev/null
+++ b/transformations/SimplifyTypesTest.hs
@@ -0,0 +1,62 @@
+{-
+Tock: a compiler for parallel languages
+Copyright (C) 2008 University of Kent
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 2 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see .
+-}
+
+-- | Tests for 'SimplifyTypes'.
+module SimplifyTypesTest (tests) where
+
+import Control.Monad.State
+import Data.Generics
+import Test.HUnit hiding (State)
+
+import CompState
+import qualified AST as A
+import Metadata
+import Pattern
+import SimplifyTypes
+import TagAST
+import TestUtils
+import TreeUtils
+
+m :: Meta
+m = emptyMeta
+
+setupState :: State CompState ()
+setupState
+ = do defineUserDataType "MYINT" A.Int
+
+testResolveNamedTypes :: Test
+testResolveNamedTypes = TestLabel "testResolveNamedTypes" $ TestList
+ [ ok 0 A.Int
+ A.Int
+ , ok 1 myint
+ A.Int
+ , ok 2 (array10 myint)
+ (array10 A.Int)
+ ]
+ where
+ ok :: (Data a, Data b) => Int -> a -> b -> Test
+ ok n inp exp = TestCase $ testPass ("testResolveNamedTypes" ++ show n)
+ exp resolveNamedTypes inp setupState
+
+ myint = A.UserDataType (simpleName "MYINT")
+ array10 = A.Array [dimension 10]
+
+tests :: Test
+tests = TestLabel "SimplifyTypesTest" $ TestList
+ [ testResolveNamedTypes
+ ]