summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/lib/IO/openFile001.hs
blob: f34f093d38dc3c69cc12491fe92385fa8b0e5ca8 (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"