File: CpphsTest.hs

package info (click to toggle)
hugs98 98.200609.21-6
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 43,136 kB
  • sloc: haskell: 118,978; xml: 61,802; ansic: 46,695; sh: 8,750; cpp: 6,033; makefile: 2,663; yacc: 1,111; cs: 883; sed: 10
file content (58 lines) | stat: -rw-r--r-- 2,087 bytes parent folder | download | duplicates (5)
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
-- Note: this file is no longer up-to-date with respect to tests/runtests
-}
module Main where

import RunCpphs ( 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