# HG changeset patch # User stephent # Date 1107344241 0 # Node ID 60989130c7064f80d71b24f055708eaec31feef4 # Parent d5df0f14fac09c99e5fd8319e858f2f9d394ec1f [xemacs-hg @ 2005-02-02 11:37:18 by stephent] Shy groups tests <87fz0f6vog.fsf@tleepslib.sk.tsukuba.ac.jp> diff -r d5df0f14fac0 -r 60989130c706 tests/ChangeLog --- a/tests/ChangeLog Tue Feb 01 22:51:18 2005 +0000 +++ b/tests/ChangeLog Wed Feb 02 11:37:21 2005 +0000 @@ -1,3 +1,13 @@ +2005-02-01 Vin Shelton + + * automated/regexp-tests.el: Added test for stale match data with + shy groups authored by Arnaud Giersch + +2005-01-13 Stephen J. Turnbull + + * automated/regexp-tests.el: + Test trivial subpatterns and backreferences with shy groups. + 2004-10-28 Stephen J. Turnbull * automated/os-tests.el: New file. Add tests for bug reported by diff -r d5df0f14fac0 -r 60989130c706 tests/automated/regexp-tests.el --- a/tests/automated/regexp-tests.el Tue Feb 01 22:51:18 2005 +0000 +++ b/tests/automated/regexp-tests.el Wed Feb 02 11:37:21 2005 +0000 @@ -393,7 +393,13 @@ (Assert (string= (progn (string-match "\\(a\\)" a) (string-match "b" a) (match-string 1 a)) - a))) + a)) + ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared, + ;; resulting in stale match data + (Assert (progn (string-match "\\(a\\)" a) + (string-match "\\(?:a\\)" a) + (not (match-beginning 1)))) + ) ;; bug identified by Katsumi Yamaoka 2004-09-03 ;; fix submitted by sjt 2004-09-08 @@ -423,3 +429,33 @@ (Assert (null (match-string 4 text))) ; nil ) +;; trivial subpatterns and backreferences with shy groups +(let ((text1 "abb") + (text2 "aba") + (re0 "\\(a\\)\\(b\\)\\2") + (re1 "\\(?:a\\)\\(b\\)\\2") + (re2 "\\(?:a\\)\\(b\\)\\1") + (re3 "\\(a\\)\\(?:b\\)\\1")) + + (Assert (eq 0 (string-match re0 text1))) + (Assert (string= text1 (match-string 0 text1))) + (Assert (string= "a" (match-string 1 text1))) + (Assert (string= "b" (match-string 2 text1))) + (Assert (null (string-match re0 text2))) + + (Check-Error-Message 'invalid-regexp "Invalid back reference" + (string-match re1 text1)) + + (Assert (eq 0 (string-match re2 text1))) + (Assert (string= text1 (match-string 0 text1))) + (Assert (string= "b" (match-string 1 text1))) + (Assert (null (match-string 2 text1))) + (Assert (null (string-match re2 text2))) + + (Assert (null (string-match re3 text1))) + (Assert (eq 0 (string-match re3 text2))) + (Assert (string= text2 (match-string 0 text2))) + (Assert (string= "a" (match-string 1 text2))) + (Assert (null (match-string 2 text2))) +) +