;; program-io.sx — tests for real IO monad (putStrLn, print, putStr).

(hk-test
  "putStrLn single line"
  (hk-run-io "main = putStrLn \"hello\"")
  (list "hello"))

(hk-test
  "putStrLn two lines via do"
  (hk-run-io "main = do { putStrLn \"a\"; putStrLn \"b\" }")
  (list "a" "b"))

(hk-test "print Int" (hk-run-io "main = print 42") (list "42"))

(hk-test "print Bool True" (hk-run-io "main = print True") (list "True"))

(hk-test
  "putStr collects string"
  (hk-run-io "main = putStr \"hello\"")
  (list "hello"))

(hk-test
  "do with let then putStrLn"
  (hk-run-io "main = do\n  let s = \"world\"\n  putStrLn s")
  (list "world"))

(hk-test
  "do sequence three lines"
  (hk-run-io "main = do { putStrLn \"1\"; putStrLn \"2\"; putStrLn \"3\" }")
  (list "1" "2" "3"))

(hk-test
  "print computed value"
  (hk-run-io "main = print (6 * 7)")
  (list "42"))

(hk-test
  "putStrLn returns IO unit"
  (hk-deep-force (hk-run "main = putStrLn \"hi\""))
  (list "IO" (list "Tuple")))

(hk-test
  "hk-run-io resets between calls"
  (begin
    (hk-run-io "main = putStrLn \"first\"")
    (hk-run-io "main = putStrLn \"second\""))
  (list "second"))

{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}
