Skip to content

Commit

Permalink
more comprehensive 'suite'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplus64 committed Feb 2, 2013
1 parent 4d4cc3c commit 884103d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Test.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,45 @@
import Language.Haskell.Repl
import Control.Monad

(-->) = (,)

main :: IO ()
main = do
repl <- newRepl
putStrLn "Started repl..."
let test label ts = do
putStrLn $ "--- " ++ label ++ " ---"
mapM_ (\(l,x') -> do x <- prompt repl x'; putStr $ l ++ ": "; mapM_ putStrLn x) ts

test "Expressions"
[ "quickly return" --> "let x = 32 in x"
, "quickly consume a line" --> "[0..]"
, "time out" --> "forever (return ()) :: Maybe ()"
, "time out and show output" --> "[0,1,2,3,let x = x in x]"
, "complete quickly and error" --> "[0,1,2,3,error \"yikes\"]"
]

test "Declarations"
[ "datatypes" --> "data X = X deriving Show"
, "newtypes" --> "newtype X' = X' X"
, "types" --> "type Y = X"
, "classes" --> "class Abc a b | a -> b"
, "instances" --> "instance Abc X X'"
, "let-bindings" --> "let x = X; x' = X' x"
]

test "Types"
[ "x :: X" --> ":t x"
, "fmapfmapfmap" --> ":t fmap fmap fmap"
]

test "Kinds"
[ ":k X" --> ":k X"
]

test "Misc"
[ "info" --> ":i Monoid"
, "undefining" --> ":d x'"
, "clear" --> ":c"
, "(try to get something)" --> ":t X"
]

0 comments on commit 884103d

Please sign in to comment.