File: CpphsTest.hs

package info (click to toggle)
cpphs 0.7-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 360 kB
  • ctags: 18
  • sloc: haskell: 939; makefile: 79; sh: 36; ansic: 11
file content (58 lines) | stat: -rw-r--r-- 2,010 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{-
-- A test module for cpphs

-- Copyright (c) 2004 Graham Klyne
-}
module Main where

import Cpphs( runCpphs )
import Test.HUnit ( Test(TestCase,TestList), Counts, assertEqual, runTestTT )

runCpphsTest :: [String] -> String -> String -> Test
runCpphsTest args result expect = TestCase $ do
  runCpphs "cpphs" (("-O"++result):args)
  res <- readFile result
  exP <- readFile expect
  assertEqual ("cpphs "++concatMap (' ':) args) exP res

test1, test2, test3, test4, test5, test6, test7, test8, test9, test10 :: Test
test1 = runCpphsTest ["-Itests/","--nomacro","tests/testfile"]
                     "tests/resultfile" "tests/expect1"
test2 = runCpphsTest ["-Itests/","--nomacro","-Dnoelif","tests/testfile"]
                     "tests/resultfile" "tests/expect2"
test3 = runCpphsTest ["-Itests/","--nomacro","-Delif","tests/testfile"]
                     "tests/resultfile" "tests/expect3"
test4 = runCpphsTest ["-Itests/","--nomacro","-Dinclude","tests/testfile"]
                     "tests/resultfile" "tests/expect4"
test5 = runCpphsTest ["-Itests/","--noline","-Dinclude","tests/testfile"]
                     "tests/resultfile" "tests/expect5"
test6 = runCpphsTest ["-Itests/","tests/cpp"]
                     "tests/resultfile" "tests/expect6"
test7 = runCpphsTest ["-Itests/","-D__GLASGOW_HASKELL__","tests/Storable.hs"]
                     "tests/resultfile" "tests/expect7"
test8 = runCpphsTest ["-Itests/","-DCALLCONV=ccall","tests/HsOpenGLExt.h"]
                     "tests/resultfile" "tests/expect8"
test9 = runCpphsTest ["-Itests/","tests/multiline"]
                     "tests/resultfile" "tests/expect9"
test10 = runCpphsTest ["-Itests/","--nomacro","tests/multiline"]
                     "tests/resultfile" "tests/expect10"

allTests :: Test
allTests = TestList
    [ test1
    , test2
    , test3
    , test4
    , test5
    , test6
    , test7
    , test8
    , test9
    , test10
    ]

run :: Test -> IO Counts
run t = runTestTT t

main :: IO ()
main = run allTests >>= print