-- $Id: Problem_2_2_a_Typing_Test.hs,v 1.2 1998/02/15 17:56:30 leavens Exp $

-- Gary T. Leavens
-- Testing for the type system of the language of Chapter 1, problem 2.2(a)

module Problem_2_2_a_Typing_Test where
import Problem_2_2_a_Parser
import CoreTypeHelpers
import Problem_2_2_a_Typing
import Problem_2_2_a_Progs
import Testing


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

pretty_type = show . type_check

tc_extract :: String -> PrimitiveAttrib
tc_extract c = let (_ ::: 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
