branch: elpa/jade-mode
commit 279df56bf9a4f9419380b1dfa73324f3831c7d1f
Author: Travis Jefferson <[email protected]>
Commit: Travis Jefferson <[email protected]>

    add some tests for indentation (new file)
    
        * tweak Makefile to run add'l test file
---
 Makefile             |  2 +-
 jade-mode.el         |  1 -
 tests/indentation.el | 26 ++++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index fef3a67f98..6ba9019f9d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
 test:
-       emacs -batch -L . -l ./tests/highlight.el -f 
ert-run-tests-batch-and-exit
+       emacs -batch -L . -l ./tests/highlight.el -l ./tests/indentation.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 35bdd07a3e..16d6fbccc7 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -317,7 +317,6 @@ Follows indentation behavior of `indent-rigidly'."
     ;; move down to the next non-blank line (or buffer end)
     (while (progn ;; progn used to get do...while control flow
              (forward-line 1)
-             (message "cur line %d" (line-number-at-pos))
              (and (jade-blank-line-p) (not (= (point-at-eol) (point-max))))))
     (let ((next-line-indent (current-indentation)))
       next-line-indent)))
diff --git a/tests/indentation.el b/tests/indentation.el
new file mode 100644
index 0000000000..43ff0ee075
--- /dev/null
+++ b/tests/indentation.el
@@ -0,0 +1,26 @@
+(require 'ert)
+(require 'jade-mode)
+
+(ert-deftest jade-mode-get-line-indentations ()
+  (with-temp-buffer
+    (insert "doctype html\nhtml\n  body\n    div\n      p content inside 
body\n")
+    (jade-mode)
+
+    ;; go to <div> line (at d of div)
+    (goto-char 30)
+    (should (looking-at "d"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))
+
+    (beginning-of-line)
+    (should (looking-at "^"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))
+
+    (end-of-line)
+    (should (looking-at "$"))
+    (should (= (current-indentation) 4))
+    (should (= (jade-next-line-indentation) 6))
+    (should (= (jade-previous-line-indentation) 2))))

Reply via email to