User: stephent
Date: 05/02/02 12:37:21
Modified: xemacs/tests/automated regexp-tests.el
Log:
Shy groups tests <87fz0f6vog.fsf(a)tleepslib.sk.tsukuba.ac.jp>
Revision Changes Path
1.63 +10 -0 XEmacs/xemacs/tests/ChangeLog
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/ChangeLog,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- ChangeLog 2004/10/28 11:31:18 1.62
+++ ChangeLog 2005/02/02 11:37:18 1.63
@@ -1,3 +1,13 @@
+2005-02-01 Vin Shelton <acs(a)xemacs.org>
+
+ * automated/regexp-tests.el: Added test for stale match data with
+ shy groups authored by Arnaud Giersch <arnaud.giersch(a)free.fr>
+
+2005-01-13 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * automated/regexp-tests.el:
+ Test trivial subpatterns and backreferences with shy groups.
+
2004-10-28 Stephen J. Turnbull <stephen(a)xemacs.org>
* automated/os-tests.el: New file. Add tests for bug reported by
1.15 +37 -1 XEmacs/xemacs/tests/automated/regexp-tests.el
(In the diff below, changes in quantity of whitespace are not shown.)
Index: regexp-tests.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/tests/automated/regexp-tests.el,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- regexp-tests.el 2004/10/07 08:01:44 1.14
+++ regexp-tests.el 2005/02/02 11:37:21 1.15
@@ -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 <b9ywtzbbpue.fsf_-_(a)jpl.org>
;; fix submitted by sjt 2004-09-08
@@ -421,5 +427,35 @@
(Assert (null (match-string 2 text))) ; ab
(Assert (null (match-string 3 text))) ; c
(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)))
)
Show replies by date