Skip to content

Commit

Permalink
ivy-test.el (swiper-isearch-backward): Add new tests
Browse files Browse the repository at this point in the history
- Note explains the discrepancy in behaviors.
  • Loading branch information
andyleejordan committed Jul 12, 2019
1 parent d73dd54 commit 1d82836
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions ivy-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,13 @@ a buffer visiting a file."
(global-set-key (kbd "C-s") #'swiper-isearch)
("C-s" "de" "" "RET"))
"abc\nasd|f123 def\ndem"))
(should
(string=
(ivy-with-text
"|(defun foo)\nasdf\n(defvar bar)"
(global-set-key (kbd "C-s") #'isearch-forward-regexp)
("C-s" "defun\\|defvar" "RET"))
"(defun| foo)\nasdf\n(defvar bar)"))
(should
(string=
(ivy-with-text
Expand All @@ -1093,6 +1100,48 @@ a buffer visiting a file."
("C-s" "defun\\|defvar" "C-n RET"))
"(defun foo)\nasdf\n(defvar| bar)")))

(ert-deftest swiper-isearch-backward ()
(should
(string=
(ivy-with-text
"abc\nasdf123 def\ndem|"
(global-set-key (kbd "C-r") #'isearch-backward-regexp)
("C-r" "de" "" "RET"))
"abc\nasdf123 def\n|dem"))
(should
(string=
(ivy-with-text
"abc\nasdf123 def\ndem|"
(global-set-key (kbd "C-r") #'swiper-isearch-backward)
("C-r" "de" "" "RET"))
"abc\nasdf123 def\n|dem"))
(should
(string=
(ivy-with-text
"(defun foo)\nasdf\n(defvar bar)|"
(global-set-key (kbd "C-r") #'isearch-backward-regexp)
("C-r" "defun\\|defvar" "RET"))
"(defun foo)\nasdf\n(|defvar bar)"))
;; NOTE: The following two behaviors do not match
;; `isearch-backward-regexp', but they match that of
;; `swiper-isearch-forward', as `swiper-isearch' does not reset the
;; point when the regexp becomes invalid, meaning the point is left
;; at the initial match of the first part of the regexp.
(should
(string=
(ivy-with-text
"(defun foo)\nasdf\n(defvar bar)|"
(global-set-key (kbd "C-r") #'swiper-isearch-backward)
("C-r" "defun\\|defvar" "RET"))
"(|defun foo)\nasdf\n(defvar bar)"))
(should
(string=
(ivy-with-text
"(defun foo)\nasdf\n(defvar bar)|"
(global-set-key (kbd "C-r") #'swiper-isearch-backward)
("C-r" "defun\\|defvar" "C-n RET"))
"(defun foo)\nasdf\n(|defvar bar)")))

(ert-deftest swiper-isearch-case-fold ()
(should
(string=
Expand Down

0 comments on commit 1d82836

Please sign in to comment.