[commit: base] master: Move tests from testsuite/tests/libraries (69f3ecd)
Ian Lynagh
igloo at earth.li
Mon May 23 21:57:36 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/69f3ecdfa4e657aea1c012640e9ab1594bcfec78
>---------------------------------------------------------------
commit 69f3ecdfa4e657aea1c012640e9ab1594bcfec78
Author: Ian Lynagh <igloo at earth.li>
Date: Sun May 8 22:04:51 2011 +0100
Move tests from testsuite/tests/libraries
>---------------------------------------------------------------
tests/all.T | 2 +
tests/fixed.hs | 19 ++++++++++++
tests/fixed.stdout | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/tempfiles.hs | 36 ++++++++++++++++++++++++
tests/tempfiles.stdout | 12 ++++++++
5 files changed, 141 insertions(+), 0 deletions(-)
diff --git a/tests/all.T b/tests/all.T
index 4906495..bc10ec0 100644
--- a/tests/all.T
+++ b/tests/all.T
@@ -2,3 +2,5 @@
test('readFloat', exit_code(1), compile_and_run, [''])
test('enumDouble', normal, compile_and_run, [''])
test('enumRatio', normal, compile_and_run, [''])
+test('tempfiles', normal, compile_and_run, [''])
+test('fixed', normal, compile_and_run, [''])
diff --git a/tests/fixed.hs b/tests/fixed.hs
new file mode 100644
index 0000000..d19bda0
--- /dev/null
+++ b/tests/fixed.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -Wall -Werror #-}
+
+module Main where
+
+import Data.Fixed
+
+nums :: Fractional a => [a]
+nums = [0,7,7.1,7.01,7.9,7.09,5 + 7,3.2 - 7.8,5.75 * (-2)]
+
+main :: IO ()
+main = do mapM_ putStrLn $ doit (nums :: [Micro])
+ mapM_ putStrLn $ doit (nums :: [Pico])
+
+doit :: HasResolution a => [Fixed a] -> [String]
+doit xs = [ showFun (signFun x)
+ | showFun <- [show, showFixed True]
+ , signFun <- [id, negate]
+ , x <- xs ]
+
diff --git a/tests/fixed.stdout b/tests/fixed.stdout
new file mode 100644
index 0000000..3c42965
--- /dev/null
+++ b/tests/fixed.stdout
@@ -0,0 +1,72 @@
+0.000000
+7.000000
+7.100000
+7.010000
+7.900000
+7.090000
+12.000000
+-4.600000
+-11.500000
+0.000000
+-7.000000
+-7.100000
+-7.010000
+-7.900000
+-7.090000
+-12.000000
+4.600000
+11.500000
+0
+7
+7.1
+7.01
+7.9
+7.09
+12
+-4.6
+-11.5
+0
+-7
+-7.1
+-7.01
+-7.9
+-7.09
+-12
+4.6
+11.5
+0.000000000000
+7.000000000000
+7.100000000000
+7.010000000000
+7.900000000000
+7.090000000000
+12.000000000000
+-4.600000000000
+-11.500000000000
+0.000000000000
+-7.000000000000
+-7.100000000000
+-7.010000000000
+-7.900000000000
+-7.090000000000
+-12.000000000000
+4.600000000000
+11.500000000000
+0
+7
+7.1
+7.01
+7.9
+7.09
+12
+-4.6
+-11.5
+0
+-7
+-7.1
+-7.01
+-7.9
+-7.09
+-12
+4.6
+11.5
diff --git a/tests/tempfiles.hs b/tests/tempfiles.hs
new file mode 100644
index 0000000..2fc1560
--- /dev/null
+++ b/tests/tempfiles.hs
@@ -0,0 +1,36 @@
+
+import Control.Exception
+import Data.List
+import System.FilePath
+import System.Directory
+import System.IO
+
+-- Checks that openTempFile returns filenames with the right structure
+main :: IO ()
+main = do
+ fp0 <- otf ".no_prefix.hs"
+ print (".hs" `isSuffixOf` fp0)
+ print (".no_prefix" `isPrefixOf` takeFileName fp0)
+
+ fp1 <- otf "no_suffix"
+ print (not ('.' `elem` fp1))
+ print ("no_suffix" `isPrefixOf` takeFileName fp1)
+
+ fp2 <- otf "one_suffix.hs"
+ print (".hs" `isSuffixOf` fp2)
+ print ("one_suffix" `isPrefixOf` takeFileName fp2)
+
+ fp3 <- otf "two_suffixes.hs.blah"
+ print (".blah" `isSuffixOf` fp3)
+ print ("two_suffixes.hs" `isPrefixOf` takeFileName fp3)
+
+otf :: FilePath -> IO FilePath
+otf fp = do putStrLn fp
+ bracket (openTempFile "." fp)
+ (\(fp', h) -> do hClose h
+ removeFile fp')
+ (\(fp', _) -> case fp' of
+ '.' : '/' : fp'' -> return fp''
+ '.' : '\\' : fp'' -> return fp''
+ _ -> return fp')
+
diff --git a/tests/tempfiles.stdout b/tests/tempfiles.stdout
new file mode 100644
index 0000000..4dc72ce
--- /dev/null
+++ b/tests/tempfiles.stdout
@@ -0,0 +1,12 @@
+.no_prefix.hs
+True
+True
+no_suffix
+True
+True
+one_suffix.hs
+True
+True
+two_suffixes.hs.blah
+True
+True
More information about the Cvs-libraries
mailing list