@@ -51,7 +51,7 @@ after a test as this aids interactive debugging."
51
51
(haskell-mode )
52
52
,@body )))
53
53
54
- (defun check-properties (lines props )
54
+ (defun check-properties (lines props &optional literate )
55
55
" Check if syntax properties and font-lock properties as set properly.
56
56
57
57
LINES is a list of strings that will be inserted to a new
@@ -63,10 +63,12 @@ if all of its characters have syntax and face. See
63
63
(kill-buffer " *haskell-mode-buffer*" ))
64
64
(save-current-buffer
65
65
(set-buffer (get-buffer-create " *haskell-mode-buffer*" ))
66
- (haskell-mode )
67
66
(dolist (line lines)
68
67
(insert line)
69
68
(insert " \n " ))
69
+ (if literate
70
+ (literate-haskell-mode )
71
+ (haskell-mode ))
70
72
(font-lock-fontify-buffer )
71
73
(goto-char (point-min ))
72
74
(dolist (prop props)
@@ -464,3 +466,91 @@ if all of its characters have syntax and face. See
464
466
(check-properties
465
467
'(" Q +++ 12.12" )
466
468
'((" +++" t haskell-definition-face))))
469
+
470
+ (ert-deftest haskell-literate-bird-1 ()
471
+ (check-properties
472
+ '(" Comment1"
473
+ " "
474
+ " > code1 = 1"
475
+ " > code2 = 1"
476
+ " "
477
+ " Comment2"
478
+ " "
479
+ " > code3 = 1"
480
+ " "
481
+ " Comment3" )
482
+ '((" Comment1" t haskell-literate-comment-face)
483
+ (" code1" t haskell-definition-face)
484
+ (" code2" t haskell-definition-face)
485
+ (" Comment2" t haskell-literate-comment-face)
486
+ (" code3" t haskell-definition-face)
487
+ (" Comment3" t haskell-literate-comment-face))
488
+ 'literate ))
489
+
490
+ (ert-deftest haskell-literate-bird-2 ()
491
+ ; ; Haskell Report requires empty line before bird code block. So it
492
+ ; ; is a code block, just in error.
493
+ :expected-result :failed
494
+ (check-properties
495
+ '(" Comment1"
496
+ " > code1 = 1"
497
+ " > code2 = 1"
498
+ " Comment2"
499
+ " "
500
+ " > code3 = 1"
501
+ " "
502
+ " Comment3" )
503
+ '((" Comment1" t haskell-literate-comment-face)
504
+ (" >" t font-lock-warning-face )
505
+ (" code1" t haskell-definition-face)
506
+ (" code2" t haskell-definition-face)
507
+ (" Comment2" t haskell-literate-comment-face)
508
+ (" code3" t haskell-definition-face)
509
+ (" Comment3" t haskell-literate-comment-face))
510
+ 'literate ))
511
+
512
+ (ert-deftest haskell-literate-latex-1 ()
513
+ (check-properties
514
+ '(" Comment1"
515
+ " "
516
+ " \\ begin{code}"
517
+ " code1 = 1"
518
+ " code2 = 1"
519
+ " \\ end{code}"
520
+ " "
521
+ " Comment2"
522
+ " \\ begin{code}"
523
+ " code3 = 1"
524
+ " \\ end{code}"
525
+ " Comment3" )
526
+ '((" Comment1" t haskell-literate-comment-face)
527
+ (" code1" t haskell-definition-face)
528
+ (" code2" t haskell-definition-face)
529
+ (" Comment2" t haskell-literate-comment-face)
530
+ (" code3" t haskell-definition-face)
531
+ (" Comment3" t haskell-literate-comment-face))
532
+ 'literate ))
533
+
534
+ (ert-deftest haskell-literate-mixed-1 ()
535
+ :expected-result :failed
536
+ ; ; Although Haskell Report does not advice mixing modes, it is a
537
+ ; ; perfectly valid construct that we should support in syntax
538
+ ; ; highlighting.
539
+ (check-properties
540
+ '(" Comment1"
541
+ " "
542
+ " > code1 = 1"
543
+ " > code2 = 1"
544
+ " "
545
+ " Comment2"
546
+ " \\ begin{code}"
547
+ " code3 = 1"
548
+ " \\ end{code}"
549
+ " Comment3" )
550
+ '((" Comment1" t haskell-literate-comment-face)
551
+ (" code1" t haskell-definition-face)
552
+ (" code2" t haskell-definition-face)
553
+ (" Comment2" t haskell-literate-comment-face)
554
+ (" code3" t haskell-definition-face)
555
+ (" Comment3" t haskell-literate-comment-face))
556
+ 'literate ))
0 commit comments