tock-mirror/RainPassTest.hs

54 lines
1.7 KiB
Haskell

module RainPassTest (tests) where
import Test.HUnit
import Control.Monad.State as CSM
import qualified Data.Map as Map
import qualified AST as A
import TestUtil
import TreeUtil
import RainPasses
import CompState
import Control.Monad.Error (runErrorT)
testEachPass0 :: Test
testEachPass0 = TestCase $ assertPatternMatch "testEachPass0" exp (evalStateT (runErrorT (transformEach orig)) emptyState)
where
orig = A.Seq m
(A.Rep m
(A.ForEach m (simpleName "c") (makeLiteralString "1"))
(A.OnlyP m (makeAssign (variable "c") (intLiteral 7)))
)
exp = tag2 A.Seq DontCare
(tag3 A.Spec DontCare
(tag3 A.Specification DontCare listVar
(tag4 A.IsExpr DontCare A.ValAbbrev (A.Array [A.Dimension 1] A.Byte) listVar)
)
(tag3 A.Rep DontCare
(tag4 A.For DontCare indexVar (intLiteral 0) (tag2 A.SizeExpr DontCare (tag2 A.ExprVariable DontCare listVar)))
(tag3 A.Spec DontCare
(tag3 A.Specification DontCare (simpleName "c")
(tag4 A.Is DontCare A.Abbrev A.Byte
(tag3 A.SubscriptedVariable DontCare
(tag2 A.Subscript DontCare (tag2 A.ExprVariable DontCare indexVar))
listVar
)
)
)
(A.OnlyP m (makeAssign (variable "c") (intLiteral 7)))
)
)
)
indexVar = Named "indexVar" DontCare
listVar = Named "listVar" DontCare
--Returns the list of tests:
tests :: Test
tests = TestList
[
testEachPass0
]