Ignore:
Timestamp:
May 3, 2014, 6:38:40 PM (11 years ago)
Author:
gobi
Message:

expressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sizechecking/branches/macs/tests/SizeTest.hs

    r22 r24  
    66import Lambda 
    77import Ops 
    8 import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool ) 
     8import Prelude ( ($), Int, (==), return, sequence, (>>=), and, (.), IO, Bool, String, const ) 
     9import qualified Control.Monad 
    910 
    1011testEmpty1 :: (Size l) => l [Unsized] 
    11 testEmpty1 = list (const 0) (lam $ \_ -> unsized) 
     12testEmpty1 = list (lit 0) (lam $ const unsized) 
    1213 
    1314testNil :: (Size l) => l [a] 
    14 testNil = list (const 0) (lam $ \_ -> bottom) 
     15testNil = list (lit 0) (lam $ const bottom) 
    1516 
    1617testHead :: (Size l) => l ([a] -> a) 
    17 testHead = slam $ \s f -> f `app` (s - const 1) 
     18testHead = slam $ \s f -> f `app` (s - lit 1) 
    1819 
    1920testTail :: (Size l) => l ([a] -> [a]) 
    20 testTail = slam $ \s f -> list (s - const 1) f 
     21testTail = slam $ \s f -> list (s - lit 1) f 
    2122 
    2223testCons :: Size l => l (a -> [a] -> [a]) 
    2324testCons = 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 
     27checkAst :: S a -> String -> IO Bool 
     28checkAst exp repr = ast exp >>= (\t -> return $ t "" == repr) 
     29 
     30tests :: [IO Bool] 
     31tests = [ 
     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 
     39runTests :: IO Bool 
     40runTests = Control.Monad.liftM and $ sequence tests 
Note: See TracChangeset for help on using the changeset viewer.