-- $Id: CoreTypeTest.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 1

module CoreTypeTest where
import CoreLangParser
import CoreTypeHelpers
import CoreTyping
import CoreLangProgs
import Testing


type_check :: String -> TreeNSubst Command
type_check = annotate . read

pretty_type = show . type_check

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

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

-- The following runs all the type checking tests

go :: IO ()
go = run_tests tc_tests
