branch: master commit 0a4ad4219b59e2b63dc914bf1dc23a81d2635b18 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy-test.el (counsel--grep-regex): Add test for negative lookahead Re #1935 --- ivy-test.el | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ivy-test.el b/ivy-test.el index 12c1077..2098194 100644 --- a/ivy-test.el +++ b/ivy-test.el @@ -344,7 +344,10 @@ will bring the behavior in line with the newer Emacsen." "bar.*baz")) (should (equal (counsel--elisp-to-pcre '(("foo\\|bar" . t) ("blah\\|bloop") ("blick" . t) ("\\(baz\\)\\|quux" . t))) - "(?:foo|bar).*blick.*(?:(baz)|quux)"))) + "(?:foo|bar).*blick.*(?:(baz)|quux)")) + (should (equal (counsel--elisp-to-pcre + '(("ivy" . t) ("-")) t) + "(?=.*ivy)(?!.*-)"))) (defmacro ivy--string-buffer (text &rest body) "Test helper that wraps TEXT in a temp buffer while running BODY." @@ -979,6 +982,15 @@ a buffer visiting a file." (should (equal out expected)) (should (equal match-data-orig (match-data))))))) +(ert-deftest counsel--grep-regex () + ;; negative lookahead: lines with "ivy", without "-" + (should + (string= + (let ((counsel--regex-look-around t) + (ivy--regex-function 'ivy--regex-plus)) + (counsel--grep-regex "ivy ! -")) + "(?=.*ivy)(?!.*-)"))) + (provide 'ivy-test) ;;; ivy-test.el ends here