emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/jade-mode 2417d49ed1 104/128: add regression tests for lin


From: ELPA Syncer
Subject: [nongnu] elpa/jade-mode 2417d49ed1 104/128: add regression tests for lines with one color
Date: Sat, 29 Jan 2022 08:24:51 -0500 (EST)

branch: elpa/jade-mode
commit 2417d49ed104a7f9e8d9e923bed8fc350d7b57b9
Author: Matthew Conway <matthew.f.conway@gmail.com>
Commit: Matthew Conway <matthew.f.conway@gmail.com>

    add regression tests for lines with one color
---
 test/highlight-test.el | 35 ++++++++++++++++-------------------
 test/test-helper.el    | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 19 deletions(-)

diff --git a/test/highlight-test.el b/test/highlight-test.el
index 21e6fd4dd2..8d9c4aafa5 100644
--- a/test/highlight-test.el
+++ b/test/highlight-test.el
@@ -4,25 +4,22 @@
     (should (null (jade-mode)))))
 
 (ert-deftest jade-mode-highlight-doctype ()
-  (with-temp-buffer
-
-    ;; interesting - if you omit the trailing newline in the string,
-    ;; `font-lock-fontify-buffer' will freak out and fail with
-    ;; end-of-buffer
-    (insert "doctype html\nhtml content\n\n")
-    (jade-mode)
-
-    ;; temp buffers require explict fontification
-    (font-lock-fontify-buffer)
-
-    ;; face at char 1 should be `font-lock-comment-face'
+  (jade-test-with-temp-buffer-pt-min
+      "doctype html\n\n"
+    (should (eq (get-text-property 1 'face)
+                'font-lock-comment-face))
     (should (eq
-             (get-text-property 1  'face)
-             'font-lock-comment-face))
-    (goto-char 1)
-
-    ;; face shouldn't change (from `font-lock-comment-face') b/t char
-    ;; 1 and eol
-    (should (=
              (next-single-property-change (point) 'face)
              (point-at-eol)))))
+
+(ert-deftest jade-mode-highlights-in-isolation ()
+  (jade-test-highlight-one-word "doctype html" 'font-lock-comment-face 0)
+  (jade-test-highlight-one-word "head" 'font-lock-function-name-face 1)
+  (jade-test-highlight-one-word "body" 'font-lock-function-name-face 2)
+  (jade-test-highlight-one-word "#container" 'font-lock-variable-name-face 2)
+  (jade-test-highlight-one-word ".class" 'font-lock-type-face 2)
+  (jade-test-highlight-one-word "if" 'font-lock-keyword-face 2)
+  (jade-test-highlight-one-word "// this is a comment" 'font-lock-comment-face 
2)
+  (jade-test-highlight-one-word "//- this is a comment" 
'font-lock-comment-face 2)
+  (jade-test-highlight-one-word "//- this is a comment" 
'font-lock-comment-face 2)
+  (jade-test-highlight-one-word "-// this is a comment" 
'font-lock-comment-face 2))
diff --git a/test/test-helper.el b/test/test-helper.el
new file mode 100644
index 0000000000..84174d3eae
--- /dev/null
+++ b/test/test-helper.el
@@ -0,0 +1,44 @@
+;;; test-helper.el --- macros and functions for testing jade-mode.el based on 
python-mode.el ert test-suite
+
+;; Copyright (C) 2015
+
+;; Author:  <matt@Akshobya>
+
+;; test highlighting based on python mode 
https://github.com/jkitchin/jmax/blob/master/python-mode/test/py-ert-tests.el
+
+(defmacro jade-test-with-temp-buffer-pt-max (contents &rest body)
+  "Creates a temp buffer in `jade-mode' inserting CONTENTS. BODY is code to be 
executed within temp buffer. Point is placed at end-of-buffer"
+  (declare (indent 0) (debug t))
+  `(with-temp-buffer
+     (jade-mode)
+     (insert ,contents)
+     (font-lock-fontify-buffer)
+     ,@body))
+
+(defmacro jade-test-with-temp-buffer-pt-min (contents &rest body)
+  "Creates a temp buffer in `jade-mode' inserting CONTENTS. BODY is code to be 
executed within temp buffer. Point is placed at beginning-of-buffer"
+  (declare (indent 1))
+  `(jade-test-with-temp-buffer-pt-max
+     ,contents
+     ,@(cons '(goto-char (point-min)) body)))
+
+(defun jade-test-go-to (string)
+  (and (eq (point) (point-max)) (goto-char (point-min)))
+  (search-forward string nil t 1))
+
+(defmacro jade-test-highlight-one-word (word face n)
+  `(jade-test-with-temp-buffer-pt-min
+       ,(concat (s-repeat n "\t") word "\n\n")
+     (print (buffer-string))
+     (should (eq (get-text-property
+                  ,(+ 1 n) 'face)
+                 ,face))
+     (goto-char ,(+ 1 n))
+     (should (eq
+              (next-single-property-change (point) 'face)
+              (point-at-eol)))))
+
+
+
+
+(byte-to-string 108)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]