Skip to content

Commit

Permalink
Fix rendering bug with parentheses.
Browse files Browse the repository at this point in the history
  • Loading branch information
leepike committed May 17, 2012
1 parent d139942 commit 10f0d96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion TODO.md
Expand Up @@ -26,7 +26,6 @@ TODO


* Make SubT from Forest into Tree(?) More natural and allows to index the head. * Make SubT from Forest into Tree(?) More natural and allows to index the head.


* Fix parentheses bug for showing Strings.


Won't Do / Can't Do Won't Do / Can't Do
----------------------------------------------- -----------------------------------------------
Expand Down
16 changes: 14 additions & 2 deletions src/Test/SmartCheck/Render.hs
Expand Up @@ -6,6 +6,7 @@ module Test.SmartCheck.Render
import Test.SmartCheck.Types import Test.SmartCheck.Types
import Test.SmartCheck.DataToTree import Test.SmartCheck.DataToTree


import Data.Maybe
import Data.Tree import Data.Tree
import Data.Data import Data.Data
import Data.List import Data.List
Expand Down Expand Up @@ -56,15 +57,26 @@ replaceWithVars format d idxs vars =


--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------


-- | Make a string out a Tree of Strings. Put parentheses around subterms. -- | Make a string out a Tree of Strings. Put parentheses around complex
-- subterms, where "complex" means we have two or more items (i.e., there's a
-- space).
stitchTree :: Tree String -> String stitchTree :: Tree String -> String
stitchTree = stitch stitchTree = stitch
where where
stitch (Node str forest) = str ++ " " ++ (unwords $ map stitchTree' forest) stitch (Node str forest) = str ++ " " ++ (unwords $ map stitchTree' forest)


stitchTree' (Node str []) = str stitchTree' (Node str []) = if isJust $ find isSpace str
then '(' : str ++ ")"
else str
stitchTree' node = '(' : stitch node ++ ")" stitchTree' node = '(' : stitch node ++ ")"


-- stitchTree' (Node str rst) | find isSpace str =
-- stitch (Node '(' : stitch str ++ ")" )'(' : stitch str ++ ")"
-- | otherwise = stitch node

-- stitchTree' (Node str []) = str
-- stitchTree' node = '(' : stitch node ++ ")"

--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------


-- Make a Tree out of a Data value. On each level, we just use the user-defined -- Make a Tree out of a Data value. On each level, we just use the user-defined
Expand Down

0 comments on commit 10f0d96

Please sign in to comment.