]> git.eshelyaron.com Git - emacs.git/commitdiff
test/lisp/replace-tests.el: Add nested match group test
authorNick Drozd <nicholasdrozd@gmail.com>
Wed, 20 Jan 2021 01:46:17 +0000 (02:46 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Wed, 20 Jan 2021 01:46:17 +0000 (02:46 +0100)
* test/lisp/replace-tests.el (replace-regexp-bug45973): Add test
(bug#45973).

test/lisp/replace-tests.el

index 8c2682a1f131aea92877e60c553aded098d33f5d..2db570c97dd5f4ebef0af4643f9e0118caa6feff 100644 (file)
@@ -587,5 +587,18 @@ bound to HIGHLIGHT-LOCUS."
                               (get-text-property (point) 'occur-target))
           (should (funcall check-overlays has-overlay)))))))
 
+(ert-deftest replace-regexp-bug45973 ()
+  "Test for https://debbugs.gnu.org/45973 ."
+  (let ((before "1RB 1LC 1RC 1RB 1RD 0LE 1LA 1LD 1RH 0LA")
+        (after  "1LB 1RC 1LC 1LB 1LD 0RE 1RA 1RD 1LH 0RA"))
+    (with-temp-buffer
+      (insert before)
+      (goto-char (point-min))
+      (replace-regexp
+       "\\(\\(L\\)\\|\\(R\\)\\)"
+       '(replace-eval-replacement
+         replace-quote
+         (if (match-string 2) "R" "L")))
+      (should (equal (buffer-string) after)))))
 
 ;;; replace-tests.el ends here