branch: elpa/jade-mode
commit c4014d8a9caf2fb08d4355e65815383af4c42dbc
Merge: a61ad07db6 4336ae9cc4
Author: Travis Jefferson <[email protected]>
Commit: Travis Jefferson <[email protected]>
Merge pull request #50 from tjefferson08/46_unit_tests
#46 unit tests
---
.gitignore | 1 +
.travis.yml | 24 ++++++++++++++++++++++++
Makefile | 4 ++++
jade-mode.el | 8 ++++----
tests/highlight.el | 33 +++++++++++++++++++++++++++++++++
5 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000..c531d9867f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+*.elc
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..a6c03325f0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,24 @@
+language: generic
+env:
+ global:
+ - CURL=curl -fsSkL --retry 9 --retry-delay 9
+ matrix:
+ - EMACS=emacs AKA=emacs23
+ - EMACS=emacs24
+# - EMACS=emacs-snapshot
+# matrix:
+# allow_failures:
+# - env: EMACS=emacs-snapshot
+before_install:
+ - sudo add-apt-repository -y ppa:cassou/emacs
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq $EMACS
+install:
+ - if test $EMACS = emacs; then
+ $CURL
https://raw.githubusercontent.com/ohler/ert/fb3c278d/lisp/emacs-lisp/ert.el -o
ert.el;
+ $CURL http://elpa.gnu.org/packages/cl-lib-0.5.el -o cl-lib.el;
+ fi
+script:
+ - make test
+notifications:
+ email: false
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000..fef3a67f98
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+test:
+ emacs -batch -L . -l ./tests/highlight.el -f
ert-run-tests-batch-and-exit
+# Local Variables:
+# indent-tabs-mode: t
diff --git a/jade-mode.el b/jade-mode.el
index d9d78b8d82..43bc12730d 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -119,7 +119,7 @@
(jade-highlight-js-after-tag 1 font-lock-preprocessor-face)
;; doctype re-overrides some of the fontification rules
- ("!!!\\|doctype[ ]?.*" 0 font-lock-comment-face t)))
+ ("^!!!\\|doctype[ ]?.*" 0 font-lock-comment-face t)))
(defun jade-highlight-js-in-parens (limit)
"Search for a tag declaration (up to LIMIT) which contains a paren
@@ -355,10 +355,10 @@ region defined by BEG and END."
(set (make-local-variable 'comment-start) "//- ")
(set (make-local-variable 'comment-start-skip) "//-\\s-*")
- (setq-default jade-tab-width 2)
- (setq-local indent-line-function 'jade-indent-line)
+ (set (make-local-variable 'jade-tab-width) 2)
+ (set (make-local-variable 'indent-line-function) 'jade-indent-line)
(set (make-local-variable 'indent-region-function) 'jade-indent-region)
- (setq-local indent-tabs-mode nil)
+ (set (make-local-variable 'indent-tabs-mode) nil)
;; keymap
(use-local-map jade-mode-map)
diff --git a/tests/highlight.el b/tests/highlight.el
new file mode 100644
index 0000000000..868d24d953
--- /dev/null
+++ b/tests/highlight.el
@@ -0,0 +1,33 @@
+(require 'ert)
+(require 'jade-mode)
+
+(ert-deftest jade-mode-command-should-be-bound ()
+ (with-temp-buffer
+ (should (fboundp 'jade-mode))
+ (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'
+ (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)))))
+
+