branch: elpa/evil-numbers
commit 95197cac775f75b8f77a4fe31b7e6658f32d93f3
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Tests: add regression test for bug #20
---
 tests/evil-numbers-tests.el | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tests/evil-numbers-tests.el b/tests/evil-numbers-tests.el
index 27f2b880fa0..37d8892b057 100644
--- a/tests/evil-numbers-tests.el
+++ b/tests/evil-numbers-tests.el
@@ -6,7 +6,6 @@
 
 ;; See: `evil-numbers-tests.sh' for launching this script.
 
-;; TODO: tests that handle bugs: #20.
 ;; Bugs fixed in:
 ;; c37a4cf92a9cf8aa9f8bd752ea856a9d1bc6c84c
 
@@ -450,6 +449,30 @@
         ;; Restore the default value.
         (setq evil-numbers-use-cursor-at-end-of-number default-value)))))
 
+;; See bug #20.
+(ert-deftest simple-nop-blank-line-cursor-stays ()
+  "Do nothing on blank line and don't move cursor to next line.
+When incrementing on a blank line with another line after it,
+the cursor should remain on the blank line, not move to the next line."
+  (let ((text-expected "|\n0")
+        (text-initial "\n0"))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        ;; Cursor starts on the blank first line.
+        ;; Try to increment - should fail and cursor should NOT move.
+        (kbd "C-a")
+        ;; Show cursor location.
+        "a|")
+      (should (equal text-expected (buffer-string)))))
+  ;; Also test decrement.
+  (let ((text-expected "|\n0")
+        (text-initial "\n0"))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "C-x")
+        "a|")
+      (should (equal text-expected (buffer-string))))))
+
 ;; See bug #27.
 (ert-deftest simple-nop-cursor-at-end-of-line-trailing-space ()
   "Do nothing when cursor is at trailing space where forward-char can't move.

Reply via email to