From 5f30667c137356d721cbf3ff01388f07f42e1af8 Mon Sep 17 00:00:00 2001 From: Remy Goldschmidt Date: Sun, 22 May 2016 12:51:30 -0500 Subject: [PATCH 1/2] Added font lock tests for pattern synonyms (for #1313) --- tests/haskell-font-lock-tests.el | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/haskell-font-lock-tests.el b/tests/haskell-font-lock-tests.el index 6eb4c41e5..30510c19d 100644 --- a/tests/haskell-font-lock-tests.el +++ b/tests/haskell-font-lock-tests.el @@ -866,3 +866,55 @@ ("Y" t haskell-constructor-face) ("Z" t haskell-type-face) ("C" t haskell-constructor-face)))) + +(ert-deftest haskell-pattern () + "Fontify the \"pattern\" keyword in contexts related to pattern synonyms." + :expected-result :failed + (check-properties + '("pattern A = B" + "pattern A <- B" + "pattern A ← B" + "pattern A n <- (subtract 1 -> n) where A n = n + 1" + "module Main (pattern A) where" + "pattern A :: a -> B" + "pattern A :: (C a) => a -> B" + "pattern A :: (C a) => a -> B" + "pattern A :: (C a) => () => a -> B" + "pattern A :: (C a) => () => a -> B" + "pattern A :: (C a) => (C a) => a -> B" + "pattern A :: (C a) => (C a) => a -> B") + '(("pattern" t haskell-keyword-face) + ("where" t haskell-keyword-face) + ("module" t haskell-keyword-face) + ("A" t haskell-constructor-face) + ("B" t haskell-type-face) + ("C" t haskell-type-face) + ("<-" t haskell-operator-face) + ("←" t haskell-operator-face) + ("=>" t haskell-operator-face) + ("::" t haskell-operator-face) + ("+" t nil) + ("1" t nil) + ("(" t nil) + (")" t nil) + ("a" t nil) + ("subtract" t nil)))) + +(ert-deftest haskell-no-pattern-1 () + "Don't fontify \"pattern\" in contexts unrelated to pattern synonyms." + ;; This already works properly + ;;:expected-result :failed + (check-properties + '("pattern :: Int" + "pattern = 3") + '(("pattern" t haskell-definition-face)))) + +(ert-deftest haskell-no-pattern-2 () + "Don't fontify \"pattern\" in contexts unrelated to pattern synonyms." + ;; This already works properly + ;;:expected-result :failed + (check-properties + '("foo :: (a -> pattern) -> a -> pattern" + "foo pattern x = pattern x" + "bar = pattern where pattern = 5") + '(("pattern" t nil)))) From 88d8c94d6a18096e806940c3056cc08d4ac5d62f Mon Sep 17 00:00:00 2001 From: Remy Goldschmidt Date: Sun, 22 May 2016 14:14:29 -0500 Subject: [PATCH 2/2] Fixed incorrect pattern synonym font-lock tests --- tests/haskell-font-lock-tests.el | 40 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/haskell-font-lock-tests.el b/tests/haskell-font-lock-tests.el index 30510c19d..1ffea8588 100644 --- a/tests/haskell-font-lock-tests.el +++ b/tests/haskell-font-lock-tests.el @@ -883,22 +883,20 @@ "pattern A :: (C a) => () => a -> B" "pattern A :: (C a) => (C a) => a -> B" "pattern A :: (C a) => (C a) => a -> B") - '(("pattern" t haskell-keyword-face) - ("where" t haskell-keyword-face) - ("module" t haskell-keyword-face) - ("A" t haskell-constructor-face) - ("B" t haskell-type-face) - ("C" t haskell-type-face) - ("<-" t haskell-operator-face) - ("←" t haskell-operator-face) - ("=>" t haskell-operator-face) - ("::" t haskell-operator-face) - ("+" t nil) - ("1" t nil) - ("(" t nil) - (")" t nil) - ("a" t nil) - ("subtract" t nil)))) + '(("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("module" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("where" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face) + ("pattern" t haskell-keyword-face)))) (ert-deftest haskell-no-pattern-1 () "Don't fontify \"pattern\" in contexts unrelated to pattern synonyms." @@ -907,7 +905,8 @@ (check-properties '("pattern :: Int" "pattern = 3") - '(("pattern" t haskell-definition-face)))) + '(("pattern" t haskell-definition-face) + ("pattern" t haskell-definition-face)))) (ert-deftest haskell-no-pattern-2 () "Don't fontify \"pattern\" in contexts unrelated to pattern synonyms." @@ -917,4 +916,9 @@ '("foo :: (a -> pattern) -> a -> pattern" "foo pattern x = pattern x" "bar = pattern where pattern = 5") - '(("pattern" t nil)))) + '(("pattern" t nil) + ("pattern" t nil) + ("pattern" t nil) + ("pattern" t nil) + ("pattern" t nil) + ("pattern" t nil))))