Changeset 24 for sizechecking/branches/macs/tests/ExpTest.hs
- Timestamp:
- May 3, 2014, 6:38:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking/branches/macs/tests/ExpTest.hs
r23 r24 5 5 import Lambda 6 6 import Exp 7 import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool )7 import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool, String, const ) 8 8 import qualified Control.Monad 9 9 … … 12 12 13 13 testAddOne :: Exp e => e ([Int] -> [Int]) 14 testAddOne = lam $ \l -> cons ( const 1) l14 testAddOne = lam $ \l -> cons (lit 1) l 15 15 16 16 testHead :: Exp e => e ([a] -> a) 17 testHead = lam $ \l -> match l undefined $ \x _ -> x17 testHead = lam $ \l -> match l undefined const 18 18 19 19 testTail :: Exp e => e ([a] -> [a]) … … 24 24 $ \x xs -> cons x (testConcat `app` xs `app` l2) 25 25 26 test EvalNil :: IO Bool27 test EvalNil = return $ ([]::[Int]) == eval testNil26 testDCons :: Exp e => e [Int] 27 testDCons = cons (lit 1) $ cons (lit 2) nil 28 28 29 test EvalAddOne :: IO Bool30 test EvalAddOne = return $ [1::Int] == (eval $ testAddOne `app` nil)29 testD2Cons :: Exp e => e [[Int]] 30 testD2Cons = cons (cons (lit 1) nil) nil 31 31 32 testEvalTail ::IO Bool33 testEvalTail = return $ [2..6::Int] == eval testTail [1..6] 32 checkAST :: S a -> String -> IO Bool 33 checkAST exp repr = ast exp >>= (\t -> return $ t "" == repr ) 34 34 35 testEvalConcat :: IO Bool 36 testEvalConcat = return $ [1..6::Int] == eval testConcat [1,2,3] [4,5,6] 35 tests :: [ IO Bool ] 36 tests = 37 [ return $ ([]::[Int]) == eval testNil 38 , checkAST testNil "[]" 39 , return $ [1::Int] == eval (testAddOne `app` nil) 40 , checkAST testAddOne "λa.1:a" 41 , return $ [2..6::Int] == eval testTail [1..6] 42 , return $ [1..6::Int] == eval testConcat [1,2,3] [4,5,6] 43 , return $ [1,2::Int] == eval testDCons 44 , checkAST testDCons "1:2:[]" 45 , return $ [[1::Int]] == eval testD2Cons 46 , checkAST testD2Cons "(1:[]):[]" 47 ] 37 48 38 tests :: [IO Bool]39 40 tests = [ testEvalNil41 , testEvalAddOne42 , testEvalTail43 , testEvalConcat44 ]45 49 46 50 runTests :: IO Bool
Note: See TracChangeset
for help on using the changeset viewer.