annotate tests/automated/regexp-tests.el @ 2227:8e7b4a0c1a81

[xemacs-hg @ 2004-08-21 17:05:49 by michaels] 2004-08-15 Jan Rychter <jwr@xemacs.org> * window-xemacs.el (really-set-window-configuration): deal gracefully with the case when the buffer previously saved in the configuration (and that we want to switch to) has been killed. Switch to the next buffer on the buffer-list in that case.
author michaels
date Sat, 21 Aug 2004 17:05:51 +0000
parents 61179c12fbb7
children cf4470caf504
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
1 ;;; -*- coding: iso-8859-1 -*-
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
2
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
3 ;; Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
4
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
5 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org>
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
6 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
7 ;; Created: 2000
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
8 ;; Keywords: tests
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
9
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
11
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
15 ;; any later version.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
16
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
20 ;; General Public License for more details.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
21
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
25 ;; 02111-1307, USA.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
26
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
27 ;;; Synched up with: Not in FSF.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
28
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
29 ;;; Commentary:
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
30
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
31 ;; Test regular expression.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
32
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
33 (Check-Error-Message error "Trailing backslash"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
34 (string-match "\\" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
35 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
36 (string-match "a++" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
37 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
38 (string-match "a**" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
39 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
40 (string-match "a???" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
41 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
42 (string-match "[" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
43 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
44 (string-match "[abc" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
45 (Check-Error-Message error "Unmatched ) or \\\\)"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
46 (string-match "\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
47 (Check-Error-Message error "Invalid regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
48 (string-match "\\(?.\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
49 (Check-Error-Message error "Unmatched \\\\{"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
50 (string-match "a\\{" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
51 (Check-Error-Message error "Invalid content of \\\\{\\\\}"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
52 (string-match "a\\{a\\}" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
53
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
54 ;; exactn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
55
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
56 ;; string-match
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
57 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
58 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
59 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
60 (Assert (string-match "ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
61 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
62 (Assert (string-match "Ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
63 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
64 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
65 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
66 (Assert (not (string-match "ä" "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
67 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
68 (Assert (not (string-match "Ä" "ä"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
69
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
70 ;; looking-at
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
71 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
72 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
73 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
74 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
75 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
76 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
77 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
78 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
79 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
80 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
81 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
82 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
83 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
84 (Assert (not (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
85 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
86 (Assert (not (looking-at "ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
87 (Assert (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
88
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
89 ;; re-search-forward and re-search-backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
90 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
91 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
92 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
93 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
94 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
95 ;; Avoid trivial regexp.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
96 (Assert (eq 2 (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
97 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
98 (Assert (eq 2 (re-search-forward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
99 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
100 (Assert (eq 3 (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
101 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
102 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
103 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
104 (goto-char (point-max))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
105 (Assert (eq 2 (re-search-backward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
106 (goto-char (point-max))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
107 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
108 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
109 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
110 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
111 (Assert (eq 1 (re-search-backward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
112 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
113 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
114 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
115 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
116 (Assert (eq 2 (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
117 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
118 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
119 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
120 (Assert (not (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
121 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
122 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
123 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
124 (goto-char (point-max))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
125 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
126 (goto-char (point-max))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
127 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
128 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
129 (Assert (eq 1 (re-search-backward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
130 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
131 (Assert (not (re-search-backward "Ä\\|a" nil t))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
132
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
133 ;; duplicate
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
134 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
135 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
136 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
137 (Assert (string-match "^\\(ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
138 (Assert (string-match "^\\(ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
139 (Assert (string-match "^\\(ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
140 (Assert (string-match "^\\(Ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
141 (Assert (string-match "^\\(Ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
142 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
143 (Assert (string-match "^\\(Ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
144 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
145 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
146 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
147 (Assert (not (string-match "^\\(ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
148 (Assert (not (string-match "^\\(ä\\)\\1$" "ÄÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
149 (Assert (not (string-match "^\\(ä\\)\\1$" "Ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
150 (Assert (not (string-match "^\\(Ä\\)\\1$" "ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
151 (Assert (not (string-match "^\\(Ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
152 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
153 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
154
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
155 ;; multiple-match
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
156 ;; Thanks to Manfred Bartz <MBartz@xix.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
157 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
158 ;; #### Need to do repetitions of more complex regexps
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
159 ;; #### WASH ME!
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
160 (with-temp-buffer
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
161 (Assert (not (string-match "^a\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
162 (Assert (string-match "^a\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
163 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
164 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
165 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
166 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
167 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
168 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
169 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
170 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
171 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
172 (Assert (string-match "^[a]\\{3,5\\}$" "aaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
173 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
174 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
175 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
176 (insert "\
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
177 aa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
178 aaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
179 aaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
180 aaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
181 aaaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
182 baaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
183 ")
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
184 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
185 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
186 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
187 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
188 (Assert (looking-at "^a\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
189 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
190 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
191 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
192 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
193 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
194 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
195 (Assert (looking-at "^[a]\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
196 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
197 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
198 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
199 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
200 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
201 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
202 (Assert (looking-at "^\\(a\\)\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
203 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
204 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
205 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
206 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
207 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
208 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
209 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
210 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
211 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
212 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
213 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
214 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
215 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
216 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
217 (Assert (= 12 (re-search-forward "a\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
218 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
219 (Assert (= 12 (re-search-forward "b?a\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
220 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
221 (Assert (= 31 (re-search-forward "ba\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
222 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
223 (Assert (= 31 (re-search-forward "[b]a\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
224 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
225 (Assert (= 31 (re-search-forward "\\(b\\)a\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
226 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
227 (Assert (= 12 (re-search-forward "^a\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
228 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
229 (Assert (= 12 (re-search-forward "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
230 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
231 (Assert (= 12 (re-search-forward "[a]\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
232 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
233 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
234 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
235 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
236 )
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
237
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
238 ;; charset, charset_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
239 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
240 (defun test-regexp-charset-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
241 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
242 (max (expt 2 (if (featurep 'mule) 19 8)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
243 (range "[a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
244 (range-not "[^a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
245 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
246 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
247 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
248 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
249 (if (or (and (<= 65 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
250 (<= i 90))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
251 (and (<= 97 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
252 (<= i 122)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
253 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
254 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
255 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
256 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
257 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
258 (setq i (1+ i)))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
259
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
260 ;; (test-regexp-charset-paranoid)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
261
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
262 ;; charset_mule, charset_mule_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
263 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
264 (defun test-regex-charset-mule-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
265 (if (featurep 'mule)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
266 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
267 (max (expt 2 19))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
268 (range (format "[%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
269 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
270 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
271 (range-not (format "[^%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
272 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
273 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
274 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
275 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
276 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
277 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
278 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
279 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
280 (if (and (<= min-int i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
281 (<= i max-int))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
282 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
283 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
284 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
285 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
286 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
287 (setq i (1+ i))))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
288
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
289 ;; (test-regex-charset-mule-paranoid)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
290
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
291 ;; Test that replace-match does not clobber registers after a failed match
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
292 (with-temp-buffer
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
293 (insert "This is a test buffer.")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
294 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
295 (search-forward "this is a test ")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
296 (looking-at "Unmatchable text")
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
297 (replace-match "")
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
298 (Assert (looking-at "^buffer.$")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
299
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
300 ;; Test that trivial regexps reset unused registers
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
301 ;; Thanks to Martin Sternholm for the report.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
302 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com>
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
303 (with-temp-buffer
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
304 (insert "ab")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
305 (goto-char (point-min))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
306 (re-search-forward "\\(a\\)")
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
307 ;; test the whole-match data, too -- one attempted fix scotched that, too!
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
308 (Assert (string= (match-string 0) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
309 (Assert (string= (match-string 1) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
310 (re-search-forward "b")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
311 (Assert (string= (match-string 0) "b"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
312 (Assert (string= (match-string 1) nil)))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
313
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
314 ;; Test word boundaries
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
315 (Assert (= (string-match "\\<a" " a") 1))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
316 (Assert (= (string-match "a\\>" "a ") 0))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
317 (Assert (= (string-match "\\ba" " a") 1))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
318 (Assert (= (string-match "a\\b" "a ") 0))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
319 ;; should work at target boundaries
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
320 (Assert (= (string-match "\\<a" "a") 0))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
321 (Assert (= (string-match "a\\>" "a") 0))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
322 (Assert (= (string-match "\\ba" "a") 0))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
323 (Assert (= (string-match "a\\b" "a") 0))
1095
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
324 ;; Check for weirdness
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
325 (Assert (not (string-match " \\> " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
326 (Assert (not (string-match " \\< " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
327 (Assert (not (string-match " \\b " " ")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
328 ;; but not if the "word" would be on the null side of the boundary!
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
329 (Assert (not (string-match "\\<" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
330 (Assert (not (string-match "\\>" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
331 (Assert (not (string-match " \\<" " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
332 (Assert (not (string-match "\\> " " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
333 (Assert (not (string-match "a\\<" "a")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
334 (Assert (not (string-match "\\>a" "a")))
1389
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
335 ;; Added Known-Bug 2002-09-09 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
336 ;; Fixed bug 2003-03-21 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
337 (Assert (not (string-match "\\b" "")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
338 (Assert (not (string-match "\\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
339 (Assert (not (string-match " \\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
340 (Assert (not (string-match "\\b " " ")))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
341
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
342 ;; Character classes are broken in Mule as of 21.5.9
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
343 ;; Added Known-Bug 2002-12-27
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
344 ;; Fixed by Daiki Ueno 2003-03-24
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
345 (if (featurep 'mule)
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
346 ;; note: (int-to-char 65) => ?A
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
347 (let ((ch0 (make-char 'japanese-jisx0208 52 65))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
348 (ch1 (make-char 'japanese-jisx0208 51 65)))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
349 (Assert (not (string-match "A" (string ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
350 (Assert (not (string-match "[A]" (string ch0))))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
351 (Assert (eq (string-match "[^A]" (string ch0)) 0))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
352 (Assert (not (string-match "@A" (string ?@ ch0))))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
353 (Assert (not (string-match "@[A]" (string ?@ ch0))))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
354 (Assert (eq (string-match "@[^A]" (string ?@ ch0)) 0))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
355 (Assert (not (string-match "@?A" (string ?@ ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
356 (Assert (not (string-match "A" (string ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
357 (Assert (not (string-match "[A]" (string ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
358 (Assert (eq (string-match "[^A]" (string ch1)) 0))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
359 (Assert (not (string-match "@A" (string ?@ ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
360 (Assert (not (string-match "@[A]" (string ?@ ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
361 (Assert (eq (string-match "@[^A]" (string ?@ ch1)) 0))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
362 (Assert (not (string-match "@?A" (string ?@ ch1))))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
363 )
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
364 )
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
365
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
366 ;; More stale match data tests.
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
367 ;; Thanks to <bjacob@ca.metsci.com>.
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
368 ;; These tests used to fail because we cleared match data only on success.
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
369 ;; Fixed 2003-04-17.
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
370 ;; Must change sense of failing tests 2003-05-09. Too much code depends on
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
371 ;; failed matches preserving match-data.
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
372 (let ((a "a"))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
373 (Assert (string= (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
374 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
375 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
376 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
377 (Assert (not (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
378 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
379 (match-string 1 a))))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
380 ;; test both for the second match is a plain string match and a regexp match
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
381 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
382 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
383 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
384 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
385 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
386 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
387 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
388 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
389 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
390 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
391 (match-string 1 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
392 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
393 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
394 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
395 (match-string 1 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
396 a)))