diff --git a/compiler/SourceSyntax/Pattern.hs b/compiler/SourceSyntax/Pattern.hs index 0328091..91d0cfc 100644 --- a/compiler/SourceSyntax/Pattern.hs +++ b/compiler/SourceSyntax/Pattern.hs @@ -35,7 +35,7 @@ instance Pretty Pattern where PData name ps -> if isTuple name then PP.parens . commaCat $ map pretty ps - else sep (PP.text name : map prettyParens ps) + else hsep (PP.text name : map prettyParens ps) prettyParens pattern = parensIf needsThem (pretty pattern) where @@ -43,4 +43,4 @@ prettyParens pattern = parensIf needsThem (pretty pattern) case pattern of PData name (_:_) | not (isTuple name) -> True PAlias _ _ -> True - _ -> False \ No newline at end of file + _ -> False diff --git a/tests/Tests/Property.hs b/tests/Tests/Property.hs index 71c73c2..ef36da4 100644 --- a/tests/Tests/Property.hs +++ b/tests/Tests/Property.hs @@ -1,24 +1,46 @@ module Tests.Property where import Test.Framework +import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 +import Test.HUnit (assert) import Test.QuickCheck -import SourceSyntax.Literal (Literal) -import SourceSyntax.PrettyPrint (Pretty, pretty) -import Parse.Helpers (IParser, iParse) -import Parse.Literal (literal) -import Parse.Pattern (expr) +import SourceSyntax.Literal as Lit +import SourceSyntax.Pattern as Pat +import SourceSyntax.PrettyPrint (Pretty, pretty) +import Parse.Helpers (IParser, iParse) +import Parse.Literal (literal) +import Parse.Pattern (expr) import Tests.Property.Arbitrary propertyTests :: Test propertyTests = testGroup "Parse/Print Agreement Tests" [ - testProperty "Literal test" $ prop_parse_print literal + testCase "Long Pattern test" $ assert (prop_parse_print expr longPat) + , testProperty "Literal test" $ prop_parse_print literal , testProperty "Pattern test" $ prop_parse_print expr ] + where + -- This test was autogenerated from the Pattern test and should be + -- left in all its ugly glory. + longPat = Pat.PData "I" [ Pat.PLiteral (Lit.Chr '+') + , Pat.PRecord [ + "q7yclkcm7k_ikstrczv_" + , "wQRv6gKsvvkjw4b5F" + ,"c9'eFfhk9FTvsMnwF_D" + ,"yqxhEkHvRFwZ" + ,"o" + ,"nbUlCn3y3NnkVoxhW" + ,"iJ0MNy3KZ_lrs" + ,"ug" + ,"sHHsX" + ,"mRKs9d" + ,"o2KiCX5'ZRzHJfRi8" ] + , Pat.PVar "su'BrrbPUK6I33Eq" ] + prop_parse_print :: (Pretty a, Arbitrary a, Eq a) => IParser a -> a -> Bool prop_parse_print p x = either (const False) (== x) . parse_print p $ x