source: sizechecking/branches/macs/tests/ExpTest.hs @ 23

Last change on this file since 23 was 23, checked in by gobi, 11 years ago

expression

File size: 1.2 KB
RevLine 
[22]1{-# LANGUAGE NoMonomorphismRestriction #-}
2
3module Tests.ExpTest where
4
5import Lambda
6import Exp
7import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool )
[23]8import qualified Control.Monad
[22]9
10testNil :: Exp e => e [a]
11testNil = nil
12
[23]13testAddOne :: Exp e => e ([Int] -> [Int])
14testAddOne = lam $ \l -> cons (const 1) l
15
16testHead :: Exp e => e ([a] -> a)
17testHead = lam $ \l -> match l undefined $ \x _ -> x
18
19testTail :: Exp e => e ([a] -> [a])
20testTail = lam $ \l -> match l undefined $ \_ xs -> xs
21
22testConcat :: Exp e => e ([a] -> [a] -> [a])
23testConcat = lam $ \l1 -> lam $ \l2 -> match l1 l2
24    $ \x xs -> cons x (testConcat `app` xs `app` l2)
25
26testEvalNil :: IO Bool
27testEvalNil = return $ ([]::[Int]) == eval testNil
28
29testEvalAddOne :: IO Bool
30testEvalAddOne = return $ [1::Int] == (eval $ testAddOne `app` nil)
31
32testEvalTail :: IO Bool
33testEvalTail = return $ [2..6::Int] == eval testTail [1..6]
34
35testEvalConcat :: IO Bool
36testEvalConcat = return $ [1..6::Int] == eval testConcat [1,2,3] [4,5,6] 
37
38tests :: [IO Bool]
39
40tests = [ testEvalNil
41        , testEvalAddOne
42        , testEvalTail
43        , testEvalConcat
44        ]
45
46runTests :: IO Bool
47runTests = Control.Monad.liftM and $ sequence tests
Note: See TracBrowser for help on using the repository browser.