Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/97b86a8e2c9ea09014b5039e68f7ee6a62097e67

>---------------------------------------------------------------

commit 97b86a8e2c9ea09014b5039e68f7ee6a62097e67
Author: Ian Lynagh <[email protected]>
Date:   Sat Nov 19 23:43:03 2011 +0000

    Move lib/System tests to base/tests

>---------------------------------------------------------------

 tests/{Numeric => System}/Makefile              |    0 
 tests/System/all.T                              |    8 ++++++++
 tests/System/exitWith001.hs                     |    3 +++
 NHC/Makefile => tests/System/exitWith001.stdout |    0 
 tests/System/getArgs001.hs                      |    9 +++++++++
 tests/System/getArgs001.stdout                  |    1 +
 tests/System/getEnv001.hs                       |   15 +++++++++++++++
 tests/System/getEnv001.stdout                   |    2 ++
 tests/System/system001.hs                       |   14 ++++++++++++++
 tests/System/system001.stdout                   |   14 ++++++++++++++
 10 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/tests/Numeric/Makefile b/tests/System/Makefile
similarity index 100%
copy from tests/Numeric/Makefile
copy to tests/System/Makefile
diff --git a/tests/System/all.T b/tests/System/all.T
new file mode 100644
index 0000000..996946f
--- /dev/null
+++ b/tests/System/all.T
@@ -0,0 +1,8 @@
+
+test('exitWith001', exit_code(42), compile_and_run, [''])
+test('getArgs001',  normal, compile_and_run, [''])
+test('getEnv001',   normal, compile_and_run, [''])
+
+test('system001',   if_platform("i386-unknown-mingw32", expect_fail), \
+       compile_and_run, [''])
+
diff --git a/tests/System/exitWith001.hs b/tests/System/exitWith001.hs
new file mode 100644
index 0000000..38dc38a
--- /dev/null
+++ b/tests/System/exitWith001.hs
@@ -0,0 +1,3 @@
+import System.Exit (exitWith, ExitCode(..))
+
+main = exitWith (ExitFailure 42)
diff --git a/NHC/Makefile b/tests/System/exitWith001.stdout
similarity index 100%
copy from NHC/Makefile
copy to tests/System/exitWith001.stdout
diff --git a/tests/System/getArgs001.hs b/tests/System/getArgs001.hs
new file mode 100644
index 0000000..4b8df91
--- /dev/null
+++ b/tests/System/getArgs001.hs
@@ -0,0 +1,9 @@
+import System.Environment (getProgName, getArgs)
+
+main = 
+    getProgName >>= \ argv0 ->
+    putStr argv0 >>
+    getArgs >>= \ argv ->
+    sequence (map (\ x -> putChar ' ' >> putStr x) argv) >>
+    putChar '\n'
+
diff --git a/tests/System/getArgs001.stdout b/tests/System/getArgs001.stdout
new file mode 100644
index 0000000..e732087
--- /dev/null
+++ b/tests/System/getArgs001.stdout
@@ -0,0 +1 @@
+getArgs001
diff --git a/tests/System/getEnv001.hs b/tests/System/getEnv001.hs
new file mode 100644
index 0000000..745f8ea
--- /dev/null
+++ b/tests/System/getEnv001.hs
@@ -0,0 +1,15 @@
+
+import System.Environment (getEnv)
+import System.IO.Error (catchIOError, isDoesNotExistError)
+
+main :: IO ()
+main = do
+    term <- getEnv "PATH"
+    putStrLn "Got $PATH"
+    fish <- getEnv "One fish, two fish, red fish, blue fish" `catchIOError` 
getEnv_except
+    putStrLn fish
+
+getEnv_except :: IOError -> IO String
+getEnv_except ioe
+ | isDoesNotExistError ioe = return ""
+ | otherwise              = ioError ioe
diff --git a/tests/System/getEnv001.stdout b/tests/System/getEnv001.stdout
new file mode 100644
index 0000000..b191cc3
--- /dev/null
+++ b/tests/System/getEnv001.stdout
@@ -0,0 +1,2 @@
+Got $PATH
+
diff --git a/tests/System/system001.hs b/tests/System/system001.hs
new file mode 100644
index 0000000..4237d52
--- /dev/null
+++ b/tests/System/system001.hs
@@ -0,0 +1,14 @@
+-- Not run on mingw, because of /dev/null use
+
+import System.Cmd (system)
+import System.Exit (ExitCode(..), exitWith)
+
+main = 
+    system "cat dog 1>/dev/null 2>&1" >>= \ ec ->
+    case ec of
+        ExitSuccess   -> putStr "What?!?\n" >> ioError (userError "dog 
succeeded")
+        ExitFailure _ ->
+            system "cat system001.hs 2>/dev/null" >>= \ ec ->
+           case ec of
+               ExitSuccess   -> exitWith ExitSuccess
+               ExitFailure _ -> putStr "What?!?\n" >> ioError (userError "cat 
failed")
diff --git a/tests/System/system001.stdout b/tests/System/system001.stdout
new file mode 100644
index 0000000..4237d52
--- /dev/null
+++ b/tests/System/system001.stdout
@@ -0,0 +1,14 @@
+-- Not run on mingw, because of /dev/null use
+
+import System.Cmd (system)
+import System.Exit (ExitCode(..), exitWith)
+
+main = 
+    system "cat dog 1>/dev/null 2>&1" >>= \ ec ->
+    case ec of
+        ExitSuccess   -> putStr "What?!?\n" >> ioError (userError "dog 
succeeded")
+        ExitFailure _ ->
+            system "cat system001.hs 2>/dev/null" >>= \ ec ->
+           case ec of
+               ExitSuccess   -> exitWith ExitSuccess
+               ExitFailure _ -> putStr "What?!?\n" >> ioError (userError "cat 
failed")



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to