Changeset 24 for sizechecking/branches/macs/tests/SizeTest.hs
- Timestamp:
- May 3, 2014, 6:38:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sizechecking/branches/macs/tests/SizeTest.hs
r22 r24 6 6 import Lambda 7 7 import Ops 8 import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool ) 8 import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool, String, const ) 9 import qualified Control.Monad 9 10 10 11 testEmpty1 :: (Size l) => l [Unsized] 11 testEmpty1 = list ( const 0) (lam $ \_ ->unsized)12 testEmpty1 = list (lit 0) (lam $ const unsized) 12 13 13 14 testNil :: (Size l) => l [a] 14 testNil = list ( const 0) (lam $ \_ ->bottom)15 testNil = list (lit 0) (lam $ const bottom) 15 16 16 17 testHead :: (Size l) => l ([a] -> a) 17 testHead = slam $ \s f -> f `app` (s - const 1)18 testHead = slam $ \s f -> f `app` (s - lit 1) 18 19 19 20 testTail :: (Size l) => l ([a] -> [a]) 20 testTail = slam $ \s f -> list (s - const 1) f21 testTail = slam $ \s f -> list (s - lit 1) f 21 22 22 23 testCons :: Size l => l (a -> [a] -> [a]) 23 24 testCons = lam $ \x -> slam $ \s f -> 24 list (s + const 1) $ shift f s (lam $ \_ -> x) 25 list (s + lit 1) $ shift f s (lam $ const x) 26 27 checkAst :: S a -> String -> IO Bool 28 checkAst exp repr = ast exp >>= (\t -> return $ t "" == repr) 29 30 tests :: [IO Bool] 31 tests = [ 32 checkAst testEmpty1 "List 0 (λa.U)" 33 , checkAst testNil "List 0 (λa.âŽ)" 34 , checkAst testHead "Îa,b.b (a-1)" 35 , checkAst testTail "Îa,b.List (a-1) b" 36 , checkAst testCons "λa.Îb,c.List (b+1) (Shift c b (λd.a))" 37 ] 38 39 runTests :: IO Bool 40 runTests = Control.Monad.liftM and $ sequence tests
Note: See TracChangeset
for help on using the changeset viewer.