summaryrefslogtreecommitdiff
path: root/libraries/base/tests/IO/openFile001.hs
blob: 1a4339c021d7c9264aef5a4ec651e0e94ea1f630 (plain)
1
2
3
4
5
6
7
8
9
10
11
-- !!! test that a file opened in ReadMode can't be written to

import System.IO
import System.IO.Error

main = do
  hIn <- openFile "openFile001.hs" ReadMode
  hPutStr hIn "test" `catchIOError` \ err ->
      if isIllegalOperation err
        then putStrLn "ok."
        else error "Oh dear\n"