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

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

diff --git a/tests/evil-numbers-tests.el b/tests/evil-numbers-tests.el
index d0ba457d43c..27f2b880fa0 100644
--- a/tests/evil-numbers-tests.el
+++ b/tests/evil-numbers-tests.el
@@ -6,7 +6,7 @@
 
 ;; See: `evil-numbers-tests.sh' for launching this script.
 
-;; TODO: tests that handle bugs: #20, #27.
+;; TODO: tests that handle bugs: #20.
 ;; Bugs fixed in:
 ;; c37a4cf92a9cf8aa9f8bd752ea856a9d1bc6c84c
 
@@ -450,5 +450,32 @@
         ;; Restore the default value.
         (setq evil-numbers-use-cursor-at-end-of-number default-value)))))
 
+;; 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.
+When the cursor is at the last blank space on a line (end of line),
+the number directly before it should NOT be manipulated."
+  ;; Test with trailing space (the exact bug #27 scenario).
+  (let ((text-expected "123 |")
+        (text-initial "123 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        ;; Move to end of line (the trailing space).
+        (kbd "<end>")
+        ;; Try to increment - should do nothing.
+        (kbd "C-a")
+        ;; Show cursor location.
+        "a|")
+      (should (equal text-expected (buffer-string)))))
+  ;; Also test decrement.
+  (let ((text-expected "123 |")
+        (text-initial "123 "))
+    (with-evil-numbers-test text-initial
+      (simulate-input
+        (kbd "<end>")
+        (kbd "C-x")
+        "a|")
+      (should (equal text-expected (buffer-string))))))
+
 (provide 'evil-numbers-tests)
 ;;; evil-numbers-tests.el ends here

Reply via email to