From ec0bf8adf774725ca1a96fe283ecf8d3ab079898 Mon Sep 17 00:00:00 2001 From: Robbie Gleichman Date: Wed, 14 Dec 2016 01:10:18 -0800 Subject: [PATCH] Add pattern unit tests. --- test/UnitTests.hs | 15 +++++++++++++++ test/VisualTranslateTests.hs | 12 +++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/test/UnitTests.hs b/test/UnitTests.hs index 17c75f2..29b85b4 100644 --- a/test/UnitTests.hs +++ b/test/UnitTests.hs @@ -289,6 +289,20 @@ enumTests = TestList [ ] ] +patternTests :: Test +patternTests = TestList[ + -- TODO Remove branch icon + assertEqualSyntaxGraphs [ + "y (F x) = x", + "y = (\\(F x) -> x)" + ] + , + assertEqualSyntaxGraphs [ + "y = let {F x y = 3} in x y", + "y = let {g = 3; F x y = g} in x y" + ] + ] + -- Yes, the commas get their own line translateUnitTests :: Test translateUnitTests = TestList [ @@ -305,6 +319,7 @@ translateUnitTests = TestList [ , TestLabel "letTests" letTests , TestLabel "negateTests" negateTests , TestLabel "enumTests" enumTests + , TestLabel "patternTests" patternTests ] allUnitTests :: Test diff --git a/test/VisualTranslateTests.hs b/test/VisualTranslateTests.hs index 01870b7..1585a06 100644 --- a/test/VisualTranslateTests.hs +++ b/test/VisualTranslateTests.hs @@ -131,19 +131,25 @@ guardTests = [ patternTests :: [String] patternTests = [ "Foo _ x = 3", + + -- TODO Remove branch icon "y (F x) = x", - "y = (\\(F x) -> x)", + "y = let {g = 3; F x y = h g} in x y", + "y = let {F x y = 3} in x y", - "y = let {g = 3; F x y = g} in x y", + "y = let F x y = g in x y", + "F x = g x", "Foo (Bar x) (Baz y) = f 1 2 x y", "Foo x y = f 1 y x", + + -- TODO Fix so that "t" connects to the apply result, not the pattern. "t@(x,y) = (x,y)", "y = let {t@(_,_) = (3,4)} in t + 3", + "y = let {(x, y) = (1,2)} in x + y", - -- TODO: Fix so that lines between patterns are Pattern Color. "y = let {(x, y) = (1,2); (z, w) = x; (m, g) = y} in foo x y z w m g", "(x:y) = 2" ]