Skip to content

Commit b51d489

Browse files
authored
Merge pull request #42 from Hi-Angel/add-font-lock-tests
Take into account a doc-comment may lack space before bar
2 parents 0f679b1 + c65f9ab commit b51d489

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

purescript-font-lock.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ that should be commented under LaTeX-style literate scripts."
326326
("\\s_\\{3,\\}" (0 (cond ((numberp (nth 4 (syntax-ppss)))
327327
;; There are no such instances inside nestable comments
328328
nil)
329-
((string-match "\\`-*\\'" (match-string 0))
329+
((string-match "\\`-*|?\\'" (match-string 0))
330330
;; Sequence of hyphens. Do nothing in
331331
;; case of things like `{---'.
332332
nil)
@@ -376,7 +376,7 @@ that should be commented under LaTeX-style literate scripts."
376376
((and purescript-font-lock-docstrings
377377
(save-excursion
378378
(goto-char (nth 8 state))
379-
(looking-at "\\(-- \\|{-\\)[ \\t]*[|^]")))
379+
(looking-at "\\(--\\|{-\\)[ \\t]*[|^]")))
380380
'font-lock-doc-face)
381381
(t 'font-lock-comment-face)))
382382

tests/purescript-font-lock-tests.el

+57-2
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ this = \"still a string\"
101101

102102
(ert-deftest docs-bar-comment-different-spacings ()
103103
(purescript-test-ranges
104-
"-- | Docs comment 1 space
104+
"--| Docs comment 0 space
105+
-- | Docs comment 1 space
105106
-- | Docs comment many spaces
106107
"
107-
'((1 57 font-lock-doc-face))))
108+
'((1 85 font-lock-doc-face))))
108109

109110
(ert-deftest docs-bar-comment-continuation ()
110111
"Acc. to
@@ -248,3 +249,57 @@ mkMyComponent = do
248249
(186 192 nil)
249250
(193 194 font-lock-type-face)
250251
(195 195 nil))))
252+
253+
(ert-deftest instance-miscellaneous ()
254+
"A diverse code snippet using `instance' (from Data.List module)"
255+
(purescript-test-ranges
256+
"instance extendNonEmptyList :: Extend NonEmptyList where
257+
extend f w@(NonEmptyList (_ :| as)) =
258+
NonEmptyList (f w :| (foldr go { val: Nil, acc: Nil } as).val)
259+
where
260+
go a { val, acc } = { val: f (NonEmptyList (a :| acc)) : val, acc: a : acc }
261+
instance semigroupNonEmptyList :: Semigroup (NonEmptyList a) where
262+
append (NonEmptyList (a :| as)) as' =
263+
NonEmptyList (a :| as <> toList as')
264+
derive newtype instance foldableNonEmptyList :: Foldable NonEmptyList
265+
"
266+
'((1 8 font-lock-keyword-face) (9 28 nil)
267+
(29 30 font-lock-variable-name-face) (31 31 nil)
268+
(32 37 font-lock-type-face) (38 38 nil)
269+
(39 50 font-lock-type-face) (51 51 nil)
270+
(52 56 font-lock-keyword-face) (57 69 nil)
271+
(70 70 font-lock-variable-name-face) (71 71 nil)
272+
(72 83 font-lock-type-face) (84 85 nil)
273+
(86 86 font-lock-keyword-face) (87 87 nil)
274+
(88 89 font-lock-type-face) (90 95 nil)
275+
(96 96 font-lock-variable-name-face) (97 101 nil)
276+
(102 113 font-lock-type-face) (114 119 nil)
277+
(120 121 font-lock-type-face) (122 137 nil)
278+
(138 138 font-lock-type-face) (139 139 nil)
279+
(140 142 font-lock-type-face) (143 147 nil)
280+
(148 148 font-lock-type-face) (149 149 nil)
281+
(150 152 font-lock-type-face) (153 158 nil)
282+
(159 159 font-lock-variable-name-face) (160 168 nil)
283+
(169 173 font-lock-keyword-face) (174 196 nil)
284+
(197 197 font-lock-variable-name-face) (198 203 nil)
285+
(204 204 font-lock-type-face) (205 208 nil)
286+
(209 220 font-lock-type-face) (221 224 nil)
287+
(225 226 font-lock-type-face) (227 233 nil)
288+
(234 234 font-lock-type-face) (235 243 nil)
289+
(244 244 font-lock-type-face) (245 247 nil)
290+
(248 248 font-lock-type-face) (249 255 nil)
291+
(256 263 font-lock-keyword-face) (264 286 nil)
292+
(287 288 font-lock-variable-name-face) (289 289 nil)
293+
(290 298 font-lock-type-face) (299 300 nil)
294+
(301 312 font-lock-type-face) (313 316 nil)
295+
(317 321 font-lock-keyword-face) (322 332 nil)
296+
(333 344 font-lock-type-face) (345 348 nil)
297+
(349 350 font-lock-type-face) (351 360 nil)
298+
(361 361 font-lock-variable-name-face) (362 366 nil)
299+
(367 378 font-lock-type-face) (379 382 nil)
300+
(383 384 font-lock-type-face) (385 388 nil)
301+
(389 390 font-lock-variable-name-face) (391 403 nil)
302+
(404 409 font-lock-keyword-face) (410 448 nil)
303+
(449 450 font-lock-variable-name-face) (451 451 nil)
304+
(452 459 font-lock-type-face) (460 460 nil)
305+
(461 472 font-lock-type-face) (473 473 nil))))

0 commit comments

Comments
 (0)