branch: elpa/evil-numbers
commit 54aa790720c29204da93d933f0e164277153c532
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>
Tests: add regression test for bug #26
Test evil-numbers-use-cursor-at-end-of-number option behavior:
- When disabled (default): numbers directly before cursor are not matched
- When enabled: numbers directly before cursor are matched and incremented
---
tests/evil-numbers-tests.el | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/tests/evil-numbers-tests.el b/tests/evil-numbers-tests.el
index fdd5e3bcfb5..d0ba457d43c 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, #26, #27.
+;; TODO: tests that handle bugs: #20, #27.
;; Bugs fixed in:
;; c37a4cf92a9cf8aa9f8bd752ea856a9d1bc6c84c
@@ -412,5 +412,43 @@
"a|")
(should (equal text-expected (buffer-string))))))
+;; See bug #26.
+(ert-deftest simple-cursor-at-end-of-number ()
+ "Check `evil-numbers-use-cursor-at-end-of-number' behavior."
+ (let ((text-initial "foo(1)"))
+ ;; Save the default value to restore later.
+ (let ((default-value evil-numbers-use-cursor-at-end-of-number))
+ (unwind-protect
+ (progn
+ ;; Test with option DISABLED (default VIM behavior).
+ ;; Cursor directly after a number should NOT increment it.
+ (setq evil-numbers-use-cursor-at-end-of-number nil)
+ (with-evil-numbers-test text-initial
+ (simulate-input
+ ;; Move cursor to the ')' (directly after the number).
+ "f)"
+ ;; Try to increment.
+ (kbd "C-a")
+ ;; Show cursor location.
+ "a|")
+ ;; Number should NOT be incremented.
+ (should (equal "foo(1)|" (buffer-string))))
+
+ ;; Test with option ENABLED.
+ ;; Cursor directly after a number SHOULD increment it.
+ (setq evil-numbers-use-cursor-at-end-of-number t)
+ (with-evil-numbers-test text-initial
+ (simulate-input
+ ;; Move cursor to the ')' (directly after the number).
+ "f)"
+ ;; Try to increment.
+ (kbd "C-a")
+ ;; Show cursor location.
+ "a|")
+ ;; Number SHOULD be incremented (cursor ends at number).
+ (should (equal "foo(2|)" (buffer-string)))))
+ ;; Restore the default value.
+ (setq evil-numbers-use-cursor-at-end-of-number default-value)))))
+
(provide 'evil-numbers-tests)
;;; evil-numbers-tests.el ends here