-- $Id: WhileNTypeTest.hs,v 1.4 2004/10/18 23:47:48 leavens Exp leavens $

-- Gary T. Leavens
-- Testing for the type system of the language of Chapter 2

module WhileNTypeTest where
import WhileNParser
import WhileNUnparser
import TypeHelpers
import WhileNTyping
import WhileNProgs
import Testing


type_check :: String -> TreeNSubst Program
type_check = annotate emptyTypeEnv . read

pretty_type = show . type_check

tc_extract :: String -> PrimitiveAttrib
tc_extract p = let (Tree_Subst (_ ::: Node t _) _) = type_check p
               in t

tc_tests :: [TestCase PrimitiveAttrib PrimitiveAttrib]
tc_tests = map (\(p,_) -> eqTest p (tc_extract p) Acomm) progs_with_results
           ++ map (\p -> eqTest p (tc_extract p) Aerr) type_error_progs

-- The following runs all the type checking tests

go :: IO ()
go = run_tests tc_tests
