Move tests from testsuite/tests/libraries
authorIan Lynagh <igloo@earth.li>
Sun, 8 May 2011 21:04:51 +0000 (22:04 +0100)
committerIan Lynagh <igloo@earth.li>
Mon, 23 May 2011 17:52:23 +0000 (18:52 +0100)
tests/all.T
tests/fixed.hs [new file with mode: 0644]
tests/fixed.stdout [new file with mode: 0644]
tests/tempfiles.hs [new file with mode: 0644]
tests/tempfiles.stdout [new file with mode: 0644]

index 4906495..bc10ec0 100644 (file)
@@ -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 (file)
index 0000000..d19bda0
--- /dev/null
@@ -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 (file)
index 0000000..3c42965
--- /dev/null
@@ -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 (file)
index 0000000..2fc1560
--- /dev/null
@@ -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 (file)
index 0000000..4dc72ce
--- /dev/null
@@ -0,0 +1,12 @@
+.no_prefix.hs
+True
+True
+no_suffix
+True
+True
+one_suffix.hs
+True
+True
+two_suffixes.hs.blah
+True
+True