Commit dd208059 authored by Simon Marlow's avatar Simon Marlow
Browse files

these tests moved to the directory package

parent 53ebe72e
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test('currentDirectory001', normal, compile_and_run, [''])
test('directory001', normal, compile_and_run, [''])
test('doesDirectoryExist001', normal, compile_and_run, [''])
# This test is a bit bogus. Disable for GHCi.
test('getDirContents001', omit_ways(['ghci']), compile_and_run, ['-fno-gen-manifest'])
# Depends on binary from previous run, which gets removed by the driver way=ghci
test('getPermissions001', omit_ways(['ghci']), compile_and_run, ['-cpp'])
import Directory (getCurrentDirectory, setCurrentDirectory,
createDirectory, removeDirectory, getDirectoryContents)
main = do
oldpwd <- getCurrentDirectory
createDirectory "foo"
setCurrentDirectory "foo"
~[n1, n2] <- getDirectoryContents "."
if dot n1 && dot n2
then do
setCurrentDirectory oldpwd
removeDirectory "foo"
putStr "Okay\n"
else
ioError (userError "Oops")
dot :: String -> Bool
dot "." = True
dot ".." = True
dot _ = False
import IO
import Directory
main = do
createDirectory "foo"
h <- openFile "foo/bar" WriteMode
hPutStr h "Okay\n"
hClose h
renameFile "foo/bar" "foo/baz"
renameDirectory "foo" "bar"
h <- openFile "bar/baz" ReadMode
stuff <- hGetContents h
putStr stuff
-- hClose h -- an error !
removeFile "bar/baz"
removeDirectory "bar"
-- !!! "/" was not recognised as a directory in 6.0.x
import System.Directory
main = doesDirectoryExist "/" >>= print
import Directory (getDirectoryContents)
import List (sort, isPrefixOf, isSuffixOf)
main = do
names <- getDirectoryContents "."
putStrLn (unlines (sort (filter ok names)))
ok name = "getDirContents" `isPrefixOf` name
&& not ("bak" `isSuffixOf` name)
&& not ("prof" `isSuffixOf` name)
&& not ("hp" `isSuffixOf` name)
&& not ("ps" `isSuffixOf` name)
&& not ("aux" `isSuffixOf` name)
getDirContents001
getDirContents001.comp.stderr
getDirContents001.hi
getDirContents001.hs
getDirContents001.o
getDirContents001.run.stderr
getDirContents001.run.stdout
getDirContents001.stdout
getDirContents001.stdout-i386-unknown-mingw32
getDirContents001.comp.stderr
getDirContents001.exe
getDirContents001.hi
getDirContents001.hs
getDirContents001.o
getDirContents001.run.stderr
getDirContents001.run.stdout
getDirContents001.stdout
getDirContents001.stdout-i386-unknown-mingw32
import Directory
main = do
p <- getPermissions "."
print p
p <- getPermissions "getPermissions001.hs"
print p
#ifndef i386_unknown_mingw32
p <- getPermissions "getPermissions001"
#else
p <- getPermissions "getPermissions001.exe"
#endif
print p
Permissions {readable = True, writable = True, executable = False, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = False}
Permissions {readable = True, writable = True, executable = True, searchable = False}
Permissions {readable = True, writable = True, executable = False, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = False}
Permissions {readable = True, writable = False, executable = True, searchable = False}
Permissions {readable = True, writable = True, executable = False, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = False}
Permissions {readable = True, writable = False, executable = True, searchable = False}
Permissions {readable = True, writable = True, executable = False, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = False}
Permissions {readable = True, writable = False, executable = True, searchable = False}
Permissions {readable = True, writable = True, executable = True, searchable = True}
Permissions {readable = True, writable = True, executable = True, searchable = True}
Permissions {readable = True, writable = True, executable = True, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = True}
Permissions {readable = True, writable = True, executable = False, searchable = False}
Permissions {readable = True, writable = False, executable = True, searchable = False}
......@@ -56,7 +56,6 @@ test('misc001', extra_run_opts('misc001.hs misc001.out'), \
compile_and_run, [''])
clean(['misc001.out'])
test('copyFile001', normal, compile_and_run, [''])
test('openFile001', normal, compile_and_run, [''])
test('openFile002', exit_code(1), compile_and_run, [''])
test('openFile003', normal, compile_and_run, [''])
......
This is the data
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment