[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)
- [nongnu] elpa/jade-mode 40efeb499a 064/128: Indent using the number of lines in a region instead of the location of point within the original region., (continued)
- [nongnu] elpa/jade-mode 40efeb499a 064/128: Indent using the number of lines in a region instead of the location of point within the original region., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 2c830e70e0 075/128: Use \\' instead of $, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 519b455d1f 113/128: Add melpa badge and flycheck support note, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode ce2400711d 107/128: get mixin parameters to highlight correctly, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode fe250570ee 110/128: install cask in TCI setup, remove emacs 23 build, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 6a3a936de8 112/128: Merge pull request #57 from tjefferson08/makefile-and-mixin-cleanup, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 1ebb5134b6 119/128: Files with ".pug" extension are now detected, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 0d0bbf6073 118/128: Merge pull request #63 from robbyoconnor/fix-grammar-error, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode fd48e74686 120/128: Merge pull request #67 from Emeraude/pug-rename, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 8f8e3154e4 123/128: Derive from text-mode, remove unneeded code, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 2417d49ed1 104/128: add regression tests for lines with one color,
ELPA Syncer <=
- [nongnu] elpa/jade-mode 2b4c25161f 103/128: put jade-mode project under control of cask, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode efee8b7bda 102/128: add Cask file, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 9907c897e7 089/128: Merge pull request #41 from tjefferson08/pipe_highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 3951fc4138 108/128: add phony `test' makefile target, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode dad17dc86c 124/128: Fix package headers, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 14b2db00cb 114/128: Merge pull request #60 from robbyoconnor/add-melpa-badge-and-flycheck-note, ELPA Syncer, 2022/01/29