-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicIO.hs
More file actions
35 lines (29 loc) · 947 Bytes
/
Copy pathBasicIO.hs
File metadata and controls
35 lines (29 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module BasicIO (tests) where
import Test.Hspec (Spec, describe, it)
import Test.HUnit (assertBool, assertEqual)
tests :: Spec
tests = describe "BasicIO" $ do
testReadingChar
testReadingLine
failIO :: String -> IO a
failIO fnName =
fail $
"\n\n\t\x1B[32;1mCheck documentation\x1B[0m of \x1B[33;1m"
++ fnName
++ "\x1B[0m on:\n\t"
++ "http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html"
testReadingChar :: Spec
testReadingChar = it "getChar" $ do
putStrLn "Write: \"a\" to pass this test: "
-- NOTE: replace 'failIO' with the actual function
result <- failIO "getChar"
assertEqual ""
'a'
result
testReadingLine :: Spec
testReadingLine = it "getLine" $ do
-- NOTE: replace 'failIO' with the actual function
result <- failIO "getLine"
assertEqual "Write: \"burrito\" to pass this test"
"burrito"
result