Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve test-suite, merging in GHC tests
- Loading branch information
Showing
11 changed files
with
130 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- | Test-suite framework and utility functions. | ||
module TestUtils ( | ||
simpleMatch | ||
) where | ||
|
||
import Control.Monad | ||
import System.Exit | ||
|
||
simpleMatch :: String -> String -> String -> IO () | ||
simpleMatch test expected actual = | ||
when (actual /= expected) $ do | ||
putStrLn $ "Test `" ++ test ++ "' failed!" | ||
putStrLn "-----------------------------" | ||
putStrLn $ "Expected: " ++ expected | ||
putStrLn "-----------------------------" | ||
putStrLn $ "Actual: " ++ actual | ||
putStrLn "-----------------------------" | ||
exitFailure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
-- This code used to print an infinite string, by calling 'spaces' | ||
-- with a negative argument. There's a patch in the library now, | ||
-- which makes 'spaces' do something sensible when called with a negative | ||
-- argument, but it really should not happen at all. | ||
|
||
module UnitPP1 where | ||
|
||
import TestUtils | ||
|
||
import Text.PrettyPrint.HughesPJ | ||
|
||
ncat :: Doc -> Doc -> Doc | ||
ncat x y = nest 4 $ cat [ x, y ] | ||
|
||
d1, d2 :: Doc | ||
d1 = foldl1 ncat $ take 50 $ repeat $ char 'a' | ||
d2 = parens $ sep [ d1, text "+" , d1 ] | ||
|
||
testPP1 :: IO () | ||
testPP1 = simpleMatch "PP1" expected out | ||
where out = show d2 | ||
|
||
expected :: String | ||
expected = | ||
"(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n\ | ||
+ a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a\n\ | ||
a)" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module UnitT3911 where | ||
|
||
import Text.PrettyPrint.HughesPJ | ||
|
||
import TestUtils | ||
|
||
xs :: [Doc] | ||
xs = [text "hello", | ||
nest 10 (text "world")] | ||
|
||
d1, d2, d3 :: Doc | ||
d1 = vcat xs | ||
d2 = foldr ($$) empty xs | ||
d3 = foldr ($+$) empty xs | ||
|
||
testT3911 :: IO () | ||
testT3911 = simpleMatch "T3911" expected out | ||
where out = show d1 ++ "\n" ++ show d2 ++ "\n" ++ show d3 | ||
|
||
expected :: String | ||
expected = | ||
"hello world\n\ | ||
hello world\n\ | ||
hello\n\ | ||
world" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.