Add test for improper pattern nesting.

This commit is contained in:
Robbie Gleichman 2016-12-05 17:14:54 -08:00
parent 7f03bf54f5
commit 9fd08c7432
6 changed files with 10 additions and 3 deletions

View File

@ -46,7 +46,7 @@ parentTypeForNode n = case n of
PatternApplyNode _ _ -> PatternParent
-- The NotAParent case should never occur.
_ -> NotAParent
findParents :: ING.Graph gr => IngSyntaxGraph gr -> ING.Node -> [ING.Node]
findParents graph node = filter parentFilter $ ING.suc graph node where
parentFilter parentNode = parentNode /= node

View File

@ -6,6 +6,7 @@ import Prelude hiding (return)
-- - an special case when translating when Glance is run on its own source code.
import Diagrams.Prelude hiding ((#), (&))
import Diagrams.Backend.SVG.CmdLine
--import Diagrams.Backend.Rasterific.CmdLine
import qualified Language.Haskell.Exts as Exts
import Icons(ColorStyle(..), colorScheme, multilineComment)

View File

@ -499,6 +499,7 @@ drawingFromDecl d = drawing
evaluatedDecl = evalDecl mempty d >>= showTopLevelBinds
syntaxGraph = evalState evaluatedDecl initialIdState
drawing = collapseNodes $ syntaxGraphToFglGraph syntaxGraph
--drawing = syntaxGraphToFglGraph syntaxGraph
-- Profiling: about 1.5% of total time.
translateString :: String -> (IngSyntaxGraph FGR.Gr, Decl)

View File

@ -36,6 +36,7 @@ executable glance-exe
, haskell-src-exts
, mtl
, semigroups
, diagrams-rasterific
default-language: Haskell2010
Other-modules: Icons, Rendering, Types, Util, Translate, TranslateCore, DrawingColors, GraphAlgorithms

View File

@ -236,7 +236,8 @@ nestedTests = [
"Foo (Bar x) = 1",
"Foo (Bar x) (Baz y) = 1",
"Foo (Bar x) = f 2",
"Foo (Bar x) = f x"
"Foo (Bar x) = f x",
"y x = case x of {Just w -> (let (z,_) = w in z)}"
]
dollarTests :: [String]
@ -519,7 +520,8 @@ collapseTestStrings = [
"Foo x = 1",
"Foo (Bar x) = 1",
"Foo 1 x = 2",
"Foo (Bar x) = f x"
"Foo (Bar x) = f x",
"y x = case x of {Just w -> (let (z,_) = w in z)}"
]
makeCollapseTest :: String -> IO (Diagram B)

View File

@ -1,4 +1,6 @@
-- TODO Now --
Fix collapseNodes when run on "y x = case x of {Just w -> (let (z,_) = w in z)}"
May need to move pattern collapse to translate.
-- TODO Later --
-- Add documentation.