Commit b98ca17e authored by rwbarton's avatar rwbarton Committed by Austin Seipp

Make enum01/enum02/enum03 tests clang-compatible

... by entirely replacing the use of CPP by a custom preprocessor;
clang -E -traditional has no stringification mechanism at all.

Reviewed By: thomie, austin

Differential Revision: https://phabricator.haskell.org/D957

GHC Trac Issues: #9399
parent 0760b84e
......@@ -77,9 +77,9 @@ test('dynamic002', normal, compile_and_run, [''])
test('dynamic003', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, [''])
test('dynamic004', omit_ways(['normal', 'threaded1', 'ghci']), compile_and_run, [''])
test('dynamic005', normal, compile_and_run, [''])
test('enum01', when(fast(), skip), compile_and_run, ['-cpp'])
test('enum02', when(fast(), skip), compile_and_run, ['-cpp'])
test('enum03', when(fast(), skip), compile_and_run, ['-cpp'])
test('enum01', when(fast(), skip), compile_and_run, [''])
test('enum02', when(fast(), skip), compile_and_run, [''])
test('enum03', when(fast(), skip), compile_and_run, [''])
test('enum04', normal, compile_and_run, [''])
test('exceptionsrun001', normal, compile_and_run, [''])
test('exceptionsrun002', normal, compile_and_run, [''])
......
-- !!! Testing the Prelude's Enum instances.
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
-- The processor is a non-CPP-based equivalent of
-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
-- which is not portable to clang
module Main(main) where
import Control.Exception
......@@ -82,7 +86,6 @@ main = do
OK - on with the regression testing.
-}
#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumInt :: IO ()
......
-- !!! Testing the Int Enum instances.
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
-- The processor is a non-CPP-based equivalent of
-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
-- which is not portable to clang
module Main(main) where
import Control.Exception
......@@ -15,7 +19,6 @@ main = do
putStrLn "Testing Enum Int64:"
testEnumInt64
#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumInt8 :: IO ()
testEnumInt8 = do
......
-- !!! Testing the Word Enum instances.
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -F -pgmF ./enum_processor.py #-}
-- The processor is a non-CPP-based equivalent of
-- #define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
-- which is not portable to clang
module Main(main) where
import Control.Exception
......@@ -17,7 +21,6 @@ main = do
testEnumWord64
#define printTest(x) (do{ putStr ( " " ++ "x" ++ " = " ) ; print (x) })
testEnumWord8 :: IO ()
testEnumWord8 = do
......
#!/usr/bin/env python
import sys
def process(s):
while True:
start = s.find('printTest')
if start == -1:
return s
j0 = j = s.index('(', start) + 1
depth = 1
while depth > 0:
if s[j] == '(':
depth += 1
if s[j] == ')':
depth -= 1
j += 1
argument = s[j0:j-1]
expansion = '(do{ putStr ( " " ++ "%s" ++ " = " ) ; print (%s) })' \
% (argument, argument)
s = s[:start] + expansion + s[j:]
_, _, inputFile, outputFile = sys.argv
open(outputFile, 'w').write(process(open(inputFile, 'r').read()))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment