Skip to content

Commit dec48ff

Browse files
committed
Merge pull request #1337 from taktoa/pattern-synonym-tests
Added font lock tests for pattern synonyms (for #1313)
2 parents 995d85f + 88d8c94 commit dec48ff

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/haskell-font-lock-tests.el

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,3 +866,59 @@
866866
("Y" t haskell-constructor-face)
867867
("Z" t haskell-type-face)
868868
("C" t haskell-constructor-face))))
869+
870+
(ert-deftest haskell-pattern ()
871+
"Fontify the \"pattern\" keyword in contexts related to pattern synonyms."
872+
:expected-result :failed
873+
(check-properties
874+
'("pattern A = B"
875+
"pattern A <- B"
876+
"pattern A ← B"
877+
"pattern A n <- (subtract 1 -> n) where A n = n + 1"
878+
"module Main (pattern A) where"
879+
"pattern A :: a -> B"
880+
"pattern A :: (C a) => a -> B"
881+
"pattern A :: (C a) => a -> B"
882+
"pattern A :: (C a) => () => a -> B"
883+
"pattern A :: (C a) => () => a -> B"
884+
"pattern A :: (C a) => (C a) => a -> B"
885+
"pattern A :: (C a) => (C a) => a -> B")
886+
'(("pattern" t haskell-keyword-face)
887+
("pattern" t haskell-keyword-face)
888+
("pattern" t haskell-keyword-face)
889+
("pattern" t haskell-keyword-face)
890+
("module" t haskell-keyword-face)
891+
("pattern" t haskell-keyword-face)
892+
("where" t haskell-keyword-face)
893+
("pattern" t haskell-keyword-face)
894+
("pattern" t haskell-keyword-face)
895+
("pattern" t haskell-keyword-face)
896+
("pattern" t haskell-keyword-face)
897+
("pattern" t haskell-keyword-face)
898+
("pattern" t haskell-keyword-face)
899+
("pattern" t haskell-keyword-face))))
900+
901+
(ert-deftest haskell-no-pattern-1 ()
902+
"Don't fontify \"pattern\" in contexts unrelated to pattern synonyms."
903+
;; This already works properly
904+
;;:expected-result :failed
905+
(check-properties
906+
'("pattern :: Int"
907+
"pattern = 3")
908+
'(("pattern" t haskell-definition-face)
909+
("pattern" t haskell-definition-face))))
910+
911+
(ert-deftest haskell-no-pattern-2 ()
912+
"Don't fontify \"pattern\" in contexts unrelated to pattern synonyms."
913+
;; This already works properly
914+
;;:expected-result :failed
915+
(check-properties
916+
'("foo :: (a -> pattern) -> a -> pattern"
917+
"foo pattern x = pattern x"
918+
"bar = pattern where pattern = 5")
919+
'(("pattern" t nil)
920+
("pattern" t nil)
921+
("pattern" t nil)
922+
("pattern" t nil)
923+
("pattern" t nil)
924+
("pattern" t nil))))

0 commit comments

Comments
 (0)