summaryrefslogtreecommitdiff
path: root/testsuite/tests/codeGen/should_run/cgrun059.hs
blob: 52d2ee88a57af9a9ba3d3cc5f9c44ea6a0624e28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- GHC 6.6 compiled YHC wrong; this is a cutdown testcase (from trac #1171).

module Main where

import System.Directory

data Error
    = ErrorFileNone
    | ErrorFileMany 
        FilePath    -- file you were looking for

raiseError ErrorFileNone = error "Error: File not found"
raiseError (ErrorFileMany file) = error $ "Error: Found file multiple times: "++file

data PackageData = PackageData [FilePath] deriving Show

getModule :: PackageData -> String -> IO ()
getModule (PackageData rs@(root:rest)) file =
        do local <- testPackage root
           res <- testPackage root
           print (local, res)
           case (local,res) of
                ([x], _) -> return ()
                (_, [x]) -> return ()
                ([], []) -> raiseError $ ErrorFileNone
                (as, bs) -> if as++bs == [] then error "Empty as++bs" else raiseError $ ErrorFileMany file
    where
        testPackage pkg =
            do
                bHi <- doesFileExist ""
                return [("","") | bHi]

main = getModule (PackageData ["7"]) "13"