Add a unit tests file for SimplifyTypes.
The tests in there at the moment are pretty trivial, but I'm going to want to add more stuff to SimplifyTypes later.
This commit is contained in:
parent
8545b08aee
commit
3eeda5d821
|
@ -182,6 +182,7 @@ tocktest_SOURCES += frontends/RainTypesTest.hs
|
||||||
tocktest_SOURCES += frontends/StructureOccamTest.hs
|
tocktest_SOURCES += frontends/StructureOccamTest.hs
|
||||||
tocktest_SOURCES += transformations/PassTest.hs
|
tocktest_SOURCES += transformations/PassTest.hs
|
||||||
tocktest_SOURCES += transformations/SimplifyAbbrevsTest.hs
|
tocktest_SOURCES += transformations/SimplifyAbbrevsTest.hs
|
||||||
|
tocktest_SOURCES += transformations/SimplifyTypesTest.hs
|
||||||
|
|
||||||
pregen_sources = data/AST.hs
|
pregen_sources = data/AST.hs
|
||||||
pregen_sources += pregen/PregenUtils.hs
|
pregen_sources += pregen/PregenUtils.hs
|
||||||
|
|
|
@ -46,6 +46,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
--
|
--
|
||||||
-- * "SimplifyAbbrevsTest"
|
-- * "SimplifyAbbrevsTest"
|
||||||
--
|
--
|
||||||
|
-- * "SimplifyTypesTest"
|
||||||
|
--
|
||||||
-- * "StructureOccamTest"
|
-- * "StructureOccamTest"
|
||||||
--
|
--
|
||||||
-- * "UsageCheckTest"
|
-- * "UsageCheckTest"
|
||||||
|
@ -73,6 +75,7 @@ import qualified PreprocessOccamTest (tests)
|
||||||
import qualified RainPassesTest (tests)
|
import qualified RainPassesTest (tests)
|
||||||
import qualified RainTypesTest (ioTests)
|
import qualified RainTypesTest (ioTests)
|
||||||
import qualified SimplifyAbbrevsTest (tests)
|
import qualified SimplifyAbbrevsTest (tests)
|
||||||
|
import qualified SimplifyTypesTest (tests)
|
||||||
import qualified StructureOccamTest (tests)
|
import qualified StructureOccamTest (tests)
|
||||||
import qualified UsageCheckTest (tests)
|
import qualified UsageCheckTest (tests)
|
||||||
import TestUtils
|
import TestUtils
|
||||||
|
@ -191,6 +194,7 @@ main = do (opts, nonOpts, errs) <- getArgs >>* getOpt RequireOrder options
|
||||||
,noqc RainPassesTest.tests
|
,noqc RainPassesTest.tests
|
||||||
,noqcButIO RainTypesTest.ioTests
|
,noqcButIO RainTypesTest.ioTests
|
||||||
,noqc SimplifyAbbrevsTest.tests
|
,noqc SimplifyAbbrevsTest.tests
|
||||||
|
,noqc SimplifyTypesTest.tests
|
||||||
,noqc StructureOccamTest.tests
|
,noqc StructureOccamTest.tests
|
||||||
,noqc UsageCheckTest.tests
|
,noqc UsageCheckTest.tests
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,7 +17,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
-- | Simplify types in the AST.
|
-- | Simplify types in the AST.
|
||||||
module SimplifyTypes (simplifyTypes) where
|
module SimplifyTypes (
|
||||||
|
simplifyTypes
|
||||||
|
, resolveNamedTypes
|
||||||
|
) where
|
||||||
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
|
|
||||||
|
|
62
transformations/SimplifyTypesTest.hs
Normal file
62
transformations/SimplifyTypesTest.hs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
-}
|
||||||
|
|
||||||
|
-- | 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
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user