Mercurial > hg > xemacs-beta
annotate tests/automated/regexp-tests.el @ 5208:9fa29ec759e3
Implement suggest-key-bindings in terms of teach-extended-commands-p
2010-04-29 Aidan Kehoe <kehoea@parhasard.net>
* cmdloop.el (suggest-key-bindings):
Make this available, documenting that it's for GNU Emacs
compatibility.
Implement it in terms of teach-extended-commands-p and
teach-extended-commands-timeout, using Ben's
set-symbol-value-handler functionality.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 29 Apr 2010 16:16:47 +0100 |
parents | 0f66906b6e37 |
children | 308d34e9f07d |
rev | line source |
---|---|
446 | 1 ;;; -*- coding: iso-8859-1 -*- |
2 | |
1612 | 3 ;; Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
4 ;; Copyright (C) 2010 Ben Wing. |
446 | 5 |
6 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org> | |
1612 | 7 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org> |
446 | 8 ;; Created: 2000 |
9 ;; Keywords: tests | |
10 | |
11 ;; This file is part of XEmacs. | |
12 | |
13 ;; XEmacs is free software; you can redistribute it and/or modify it | |
14 ;; under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; XEmacs is distributed in the hope that it will be useful, but | |
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 ;; General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
26 ;; 02111-1307, USA. | |
27 | |
28 ;;; Synched up with: Not in FSF. | |
29 | |
30 ;;; Commentary: | |
31 | |
4897
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
32 ;; Test regular expressions. |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
33 |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4900
diff
changeset
|
34 ;; NOTE NOTE NOTE: There is some domain overlap among case-tests.el, |
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4900
diff
changeset
|
35 ;; regexp-tests.el and search-tests.el. See case-tests.el. |
446 | 36 |
37 (Check-Error-Message error "Trailing backslash" | |
38 (string-match "\\" "a")) | |
39 (Check-Error-Message error "Invalid preceding regular expression" | |
40 (string-match "a++" "a")) | |
41 (Check-Error-Message error "Invalid preceding regular expression" | |
42 (string-match "a**" "a")) | |
43 (Check-Error-Message error "Invalid preceding regular expression" | |
44 (string-match "a???" "a")) | |
45 (Check-Error-Message error "Unmatched \\[ or \\[^" | |
46 (string-match "[" "a")) | |
47 (Check-Error-Message error "Unmatched \\[ or \\[^" | |
48 (string-match "[abc" "a")) | |
49 (Check-Error-Message error "Unmatched ) or \\\\)" | |
50 (string-match "\\)" "a")) | |
51 (Check-Error-Message error "Invalid regular expression" | |
52 (string-match "\\(?.\\)" "a")) | |
53 (Check-Error-Message error "Unmatched \\\\{" | |
54 (string-match "a\\{" "a")) | |
55 (Check-Error-Message error "Invalid content of \\\\{\\\\}" | |
56 (string-match "a\\{a\\}" "a")) | |
57 | |
58 ;; exactn | |
59 | |
60 ;; string-match | |
61 (with-temp-buffer | |
62 ;; case-insensitive | |
63 (Assert (string-match "ä" "ä")) | |
64 (Assert (string-match "ä" "Ä")) | |
65 (Assert (string-match "Ä" "Ä")) | |
66 (Assert (string-match "Ä" "ä")) | |
67 ;; case-sensitive | |
68 (setq case-fold-search nil) | |
69 (Assert (string-match "ä" "ä")) | |
70 (Assert (not (string-match "ä" "Ä"))) | |
71 (Assert (string-match "Ä" "Ä")) | |
72 (Assert (not (string-match "Ä" "ä")))) | |
73 | |
74 ;; looking-at | |
75 (with-temp-buffer | |
76 (insert "äÄ") | |
77 ;; case-insensitive | |
78 (goto-char (point-min)) | |
79 (Assert (looking-at "ä")) | |
80 (Assert (looking-at "Ä")) | |
81 (forward-char) | |
82 (Assert (looking-at "ä")) | |
83 (Assert (looking-at "Ä")) | |
84 ;; case-sensitive | |
85 (setq case-fold-search nil) | |
86 (goto-char (point-min)) | |
87 (Assert (looking-at "ä")) | |
88 (Assert (not (looking-at "Ä"))) | |
89 (forward-char) | |
90 (Assert (not (looking-at "ä"))) | |
91 (Assert (looking-at "Ä"))) | |
92 | |
93 ;; re-search-forward and re-search-backward | |
94 (with-temp-buffer | |
95 (insert "äÄ") | |
96 ;; case insensitive | |
97 ;; forward | |
98 (goto-char (point-min)) | |
99 ;; Avoid trivial regexp. | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
100 (Assert (eq 2 (re-search-forward "ä\\|a" nil t))) |
446 | 101 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
102 (Assert (eq 2 (re-search-forward "Ä\\|a" nil t))) |
446 | 103 (goto-char (1+ (point-min))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
104 (Assert (eq 3 (re-search-forward "ä\\|a" nil t))) |
446 | 105 (goto-char (1+ (point-min))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
106 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t))) |
446 | 107 ;; backward |
108 (goto-char (point-max)) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
109 (Assert (eq 2 (re-search-backward "ä\\|a" nil t))) |
446 | 110 (goto-char (point-max)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
111 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t))) |
446 | 112 (goto-char (1- (point-max))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
113 (Assert (eq 1 (re-search-backward "ä\\|a" nil t))) |
446 | 114 (goto-char (1- (point-max))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
115 (Assert (eq 1 (re-search-backward "Ä\\|a" nil t))) |
446 | 116 ;; case sensitive |
117 (setq case-fold-search nil) | |
118 ;; forward | |
119 (goto-char (point-min)) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
120 (Assert (eq 2 (re-search-forward "ä\\|a" nil t))) |
446 | 121 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
122 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t))) |
446 | 123 (goto-char (1+ (point-min))) |
124 (Assert (not (re-search-forward "ä\\|a" nil t))) | |
125 (goto-char (1+ (point-min))) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
126 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t))) |
446 | 127 ;; backward |
128 (goto-char (point-max)) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
129 (Assert (eq 1 (re-search-backward "ä\\|a" nil t))) |
446 | 130 (goto-char (point-max)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
131 (Assert (eq 2 (re-search-backward "Ä\\|a" nil t))) |
446 | 132 (goto-char (1- (point-max))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
133 (Assert (eq 1 (re-search-backward "ä\\|a" nil t))) |
446 | 134 (goto-char (1- (point-max))) |
135 (Assert (not (re-search-backward "Ä\\|a" nil t)))) | |
136 | |
137 ;; duplicate | |
138 (with-temp-buffer | |
139 ;; case insensitive | |
140 (Assert (string-match "^\\(ä\\)\\1$" "ää")) | |
141 (Assert (string-match "^\\(ä\\)\\1$" "äÄ")) | |
142 (Assert (string-match "^\\(ä\\)\\1$" "ÄÄ")) | |
143 (Assert (string-match "^\\(ä\\)\\1$" "Ää")) | |
144 (Assert (string-match "^\\(Ä\\)\\1$" "ää")) | |
145 (Assert (string-match "^\\(Ä\\)\\1$" "äÄ")) | |
146 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ")) | |
147 (Assert (string-match "^\\(Ä\\)\\1$" "Ää")) | |
148 ;; case sensitive | |
149 (setq case-fold-search nil) | |
150 (Assert (string-match "^\\(ä\\)\\1$" "ää")) | |
151 (Assert (not (string-match "^\\(ä\\)\\1$" "äÄ"))) | |
152 (Assert (not (string-match "^\\(ä\\)\\1$" "ÄÄ"))) | |
153 (Assert (not (string-match "^\\(ä\\)\\1$" "Ää"))) | |
154 (Assert (not (string-match "^\\(Ä\\)\\1$" "ää"))) | |
155 (Assert (not (string-match "^\\(Ä\\)\\1$" "äÄ"))) | |
156 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ")) | |
157 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää")))) | |
158 | |
1714 | 159 ;; multiple-match |
160 ;; Thanks to Manfred Bartz <MBartz@xix.com> | |
161 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com> | |
162 ;; #### Need to do repetitions of more complex regexps | |
163 ;; #### WASH ME! | |
164 (with-temp-buffer | |
165 (Assert (not (string-match "^a\\{4,4\\}$" "aaa"))) | |
166 (Assert (string-match "^a\\{4,4\\}$" "aaaa")) | |
167 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa"))) | |
168 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa"))) | |
169 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa")) | |
170 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa"))) | |
171 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa"))) | |
172 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa")) | |
173 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa"))) | |
174 ;; Use class because repetition of single char broken in 21.5.15 | |
175 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa"))) | |
176 (Assert (string-match "^[a]\\{3,5\\}$" "aaa")) | |
177 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa")) | |
178 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa")) | |
179 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa"))) | |
180 (insert "\ | |
181 aa | |
182 aaa | |
183 aaaa | |
184 aaaaa | |
185 aaaaaa | |
186 baaaa | |
187 ") | |
188 (goto-char (point-min)) | |
189 (forward-line 1) | |
190 (Assert (not (looking-at "^a\\{4,4\\}$"))) | |
191 (forward-line 1) | |
192 (Assert (looking-at "^a\\{4,4\\}$")) | |
193 (forward-line 1) | |
194 (Assert (not (looking-at "^a\\{4,4\\}$"))) | |
195 (goto-char (point-min)) | |
196 (forward-line 1) | |
197 (Assert (not (looking-at "^[a]\\{4,4\\}$"))) | |
198 (forward-line 1) | |
199 (Assert (looking-at "^[a]\\{4,4\\}$")) | |
200 (forward-line 1) | |
201 (Assert (not (looking-at "^[a]\\{4,4\\}$"))) | |
202 (goto-char (point-min)) | |
203 (forward-line 1) | |
204 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$"))) | |
205 (forward-line 1) | |
206 (Assert (looking-at "^\\(a\\)\\{4,4\\}$")) | |
207 (forward-line 1) | |
208 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$"))) | |
209 ;; Use class because repetition of single char broken in 21.5.15 | |
210 (goto-char (point-min)) | |
211 (Assert (not (looking-at "^[a]\\{3,5\\}$"))) | |
212 (forward-line 1) | |
213 (Assert (looking-at "^[a]\\{3,5\\}$")) | |
214 (forward-line 1) | |
215 (Assert (looking-at "^[a]\\{3,5\\}$")) | |
216 (forward-line 1) | |
217 (Assert (looking-at "^[a]\\{3,5\\}$")) | |
218 (forward-line 1) | |
219 (Assert (not (looking-at "^[a]\\{3,5\\}$"))) | |
220 (goto-char (point-min)) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
221 (Assert (= 12 (re-search-forward "a\\{4,4\\}"))) |
1714 | 222 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
223 (Assert (= 12 (re-search-forward "b?a\\{4,4\\}"))) |
1714 | 224 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
225 (Assert (= 31 (re-search-forward "ba\\{4,4\\}"))) |
1714 | 226 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
227 (Assert (= 31 (re-search-forward "[b]a\\{4,4\\}"))) |
1714 | 228 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
229 (Assert (= 31 (re-search-forward "\\(b\\)a\\{4,4\\}"))) |
1714 | 230 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
231 (Assert (= 12 (re-search-forward "^a\\{4,4\\}"))) |
1714 | 232 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
233 (Assert (= 12 (re-search-forward "^a\\{4,4\\}$"))) |
1714 | 234 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
235 (Assert (= 12 (re-search-forward "[a]\\{4,4\\}"))) |
1714 | 236 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
237 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}"))) |
1714 | 238 (goto-char (point-min)) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
239 (Assert (= 12 (re-search-forward "^[a]\\{4,4\\}$"))) |
1714 | 240 ) |
241 | |
446 | 242 ;; charset, charset_not |
243 ;; Not called because it takes too much time. | |
244 (defun test-regexp-charset-paranoid () | |
245 (let ((i 0) | |
246 (max (expt 2 (if (featurep 'mule) 19 8))) | |
247 (range "[a-z]") | |
248 (range-not "[^a-z]") | |
249 char string) | |
250 (while (< i max) | |
251 (when (setq char (int-to-char i)) | |
252 (setq string (char-to-string char)) | |
253 (if (or (and (<= 65 i) | |
254 (<= i 90)) | |
255 (and (<= 97 i) | |
256 (<= i 122))) | |
257 (progn | |
258 (Assert (string-match range string)) | |
259 (Assert (not (string-match range-not string)))) | |
260 (Assert (not (string-match range string))) | |
261 (Assert (string-match range-not string)))) | |
262 (setq i (1+ i))))) | |
263 | |
264 ;; (test-regexp-charset-paranoid) | |
265 | |
266 ;; charset_mule, charset_mule_not | |
267 ;; Not called because it takes too much time. | |
268 (defun test-regex-charset-mule-paranoid () | |
269 (if (featurep 'mule) | |
270 (let ((i 0) | |
271 (max (expt 2 19)) | |
272 (range (format "[%c-%c]" | |
273 (make-char 'japanese-jisx0208 36 34) | |
274 (make-char 'japanese-jisx0208 36 42))) | |
275 (range-not (format "[^%c-%c]" | |
276 (make-char 'japanese-jisx0208 36 34) | |
277 (make-char 'japanese-jisx0208 36 42))) | |
278 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34))) | |
279 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42))) | |
280 char string) | |
281 (while (< i max) | |
282 (when (setq char (int-to-char i)) | |
283 (setq string (char-to-string char)) | |
284 (if (and (<= min-int i) | |
285 (<= i max-int)) | |
286 (progn | |
287 (Assert (string-match range string)) | |
288 (Assert (not (string-match range-not string)))) | |
289 (Assert (not (string-match range string))) | |
290 (Assert (string-match range-not string)))) | |
291 (setq i (1+ i)))))) | |
292 | |
293 ;; (test-regex-charset-mule-paranoid) | |
448 | 294 |
1472 | 295 ;; Test that replace-match does not clobber registers after a failed match |
448 | 296 (with-temp-buffer |
297 (insert "This is a test buffer.") | |
298 (goto-char (point-min)) | |
299 (search-forward "this is a test ") | |
300 (looking-at "Unmatchable text") | |
1472 | 301 (replace-match "") |
302 (Assert (looking-at "^buffer.$"))) | |
1024 | 303 |
304 ;; Test that trivial regexps reset unused registers | |
305 ;; Thanks to Martin Sternholm for the report. | |
306 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com> | |
307 (with-temp-buffer | |
308 (insert "ab") | |
309 (goto-char (point-min)) | |
310 (re-search-forward "\\(a\\)") | |
1175 | 311 ;; test the whole-match data, too -- one attempted fix scotched that, too! |
1024 | 312 (Assert (string= (match-string 0) "a")) |
313 (Assert (string= (match-string 1) "a")) | |
314 (re-search-forward "b") | |
315 (Assert (string= (match-string 0) "b")) | |
316 (Assert (string= (match-string 1) nil))) | |
317 | |
318 ;; Test word boundaries | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
319 (Assert (= (string-match "\\<a" " a") 1)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
320 (Assert (= (string-match "a\\>" "a ") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
321 (Assert (= (string-match "\\ba" " a") 1)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
322 (Assert (= (string-match "a\\b" "a ") 0)) |
1024 | 323 ;; should work at target boundaries |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
324 (Assert (= (string-match "\\<a" "a") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
325 (Assert (= (string-match "a\\>" "a") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
326 (Assert (= (string-match "\\ba" "a") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
327 (Assert (= (string-match "a\\b" "a") 0)) |
1095 | 328 ;; Check for weirdness |
329 (Assert (not (string-match " \\> " " "))) | |
330 (Assert (not (string-match " \\< " " "))) | |
331 (Assert (not (string-match " \\b " " "))) | |
1024 | 332 ;; but not if the "word" would be on the null side of the boundary! |
333 (Assert (not (string-match "\\<" ""))) | |
334 (Assert (not (string-match "\\>" ""))) | |
335 (Assert (not (string-match " \\<" " "))) | |
336 (Assert (not (string-match "\\> " " "))) | |
337 (Assert (not (string-match "a\\<" "a"))) | |
338 (Assert (not (string-match "\\>a" "a"))) | |
1389 | 339 ;; Added Known-Bug 2002-09-09 sjt |
340 ;; Fixed bug 2003-03-21 sjt | |
341 (Assert (not (string-match "\\b" ""))) | |
342 (Assert (not (string-match "\\b" " "))) | |
343 (Assert (not (string-match " \\b" " "))) | |
344 (Assert (not (string-match "\\b " " "))) | |
1175 | 345 |
346 ;; Character classes are broken in Mule as of 21.5.9 | |
347 ;; Added Known-Bug 2002-12-27 | |
1413 | 348 ;; Fixed by Daiki Ueno 2003-03-24 |
1175 | 349 (if (featurep 'mule) |
350 ;; note: (int-to-char 65) => ?A | |
351 (let ((ch0 (make-char 'japanese-jisx0208 52 65)) | |
352 (ch1 (make-char 'japanese-jisx0208 51 65))) | |
353 (Assert (not (string-match "A" (string ch0)))) | |
354 (Assert (not (string-match "[A]" (string ch0)))) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
355 (Assert (eq (string-match "[^A]" (string ch0)) 0)) |
1175 | 356 (Assert (not (string-match "@A" (string ?@ ch0)))) |
1413 | 357 (Assert (not (string-match "@[A]" (string ?@ ch0)))) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
358 (Assert (eq (string-match "@[^A]" (string ?@ ch0)) 0)) |
1175 | 359 (Assert (not (string-match "@?A" (string ?@ ch0)))) |
360 (Assert (not (string-match "A" (string ch1)))) | |
361 (Assert (not (string-match "[A]" (string ch1)))) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
362 (Assert (eq (string-match "[^A]" (string ch1)) 0)) |
1175 | 363 (Assert (not (string-match "@A" (string ?@ ch1)))) |
364 (Assert (not (string-match "@[A]" (string ?@ ch1)))) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
365 (Assert (eq (string-match "@[^A]" (string ?@ ch1)) 0)) |
1413 | 366 (Assert (not (string-match "@?A" (string ?@ ch1)))) |
367 ) | |
368 ) | |
1195 | 369 |
370 ;; More stale match data tests. | |
371 ;; Thanks to <bjacob@ca.metsci.com>. | |
1425 | 372 ;; These tests used to fail because we cleared match data only on success. |
373 ;; Fixed 2003-04-17. | |
1612 | 374 ;; Must change sense of failing tests 2003-05-09. Too much code depends on |
375 ;; failed matches preserving match-data. | |
1472 | 376 (let ((a "a")) |
377 (Assert (string= (progn (string-match "a" a) | |
378 (string-match "b" a) | |
379 (match-string 0 a)) | |
380 a)) | |
381 (Assert (not (progn (string-match "a" a) | |
382 (string-match "b" a) | |
383 (match-string 1 a)))) | |
384 ;; test both for the second match is a plain string match and a regexp match | |
385 (Assert (string= (progn (string-match "\\(a\\)" a) | |
386 (string-match "\\(b\\)" a) | |
387 (match-string 0 a)) | |
388 a)) | |
389 (Assert (string= (progn (string-match "\\(a\\)" a) | |
390 (string-match "b" a) | |
391 (match-string 0 a)) | |
392 a)) | |
393 (Assert (string= (progn (string-match "\\(a\\)" a) | |
394 (string-match "\\(b\\)" a) | |
395 (match-string 1 a)) | |
396 a)) | |
397 (Assert (string= (progn (string-match "\\(a\\)" a) | |
398 (string-match "b" a) | |
399 (match-string 1 a)) | |
2542 | 400 a)) |
401 ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared, | |
402 ;; resulting in stale match data | |
403 (Assert (progn (string-match "\\(a\\)" a) | |
404 (string-match "\\(?:a\\)" a) | |
405 (not (match-beginning 1)))) | |
406 ) | |
2254 | 407 |
408 ;; bug identified by Katsumi Yamaoka 2004-09-03 <b9ywtzbbpue.fsf_-_@jpl.org> | |
409 ;; fix submitted by sjt 2004-09-08 | |
410 ;; trailing comments are values from buggy 21.4.15 | |
411 (let ((text "abc")) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
412 (Assert (eq 0 (string-match "\\(?:ab+\\)*c" text))) ; 2 |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
413 (Assert (eq 0 (string-match "^\\(?:ab+\\)*c" text))) ; nil |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
414 (Assert (eq 0 (string-match "^\\(?:ab+\\)*" text))) ; 0 |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
415 (Assert (eq 0 (string-match "^\\(?:ab+\\)c" text))) ; 0 |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
416 (Assert (eq 0 (string-match "^\\(?:ab\\)*c" text))) ; 0 |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
417 (Assert (eq 0 (string-match "^\\(?:a+\\)*b" text))) ; nil |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
418 (Assert (eq 0 (string-match "^\\(?:a\\)*b" text))) ; 0 |
2254 | 419 ) |
420 | |
2324 | 421 ;; per Steve Youngs 2004-09-30 <microsoft-free.87ekkjhj7t.fsf@youngs.au.com> |
422 ;; fix submitted by sjt 2004-10-07 | |
423 ;; trailing comments are values from buggy 21.4.pre16 | |
424 (let ((text "abc")) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
425 (Assert (eq 0 (string-match "\\(?:a\\(b\\)\\)" text))) ; 0 |
2324 | 426 (Assert (string= (match-string 1 text) "b")) ; ab |
427 (Assert (null (match-string 2 text))) ; b | |
428 (Assert (null (match-string 3 text))) ; nil | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
429 (Assert (eq 0 (string-match "\\(?:a\\(?:b\\(c\\)\\)\\)" text))) ; 0 |
2324 | 430 (Assert (string= (match-string 1 text) "c")) ; abc |
431 (Assert (null (match-string 2 text))) ; ab | |
432 (Assert (null (match-string 3 text))) ; c | |
433 (Assert (null (match-string 4 text))) ; nil | |
434 ) | |
435 | |
2542 | 436 ;; trivial subpatterns and backreferences with shy groups |
437 (let ((text1 "abb") | |
438 (text2 "aba") | |
439 (re0 "\\(a\\)\\(b\\)\\2") | |
440 (re1 "\\(?:a\\)\\(b\\)\\2") | |
441 (re2 "\\(?:a\\)\\(b\\)\\1") | |
442 (re3 "\\(a\\)\\(?:b\\)\\1")) | |
443 | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
444 (Assert (eq 0 (string-match re0 text1))) |
2542 | 445 (Assert (string= text1 (match-string 0 text1))) |
446 (Assert (string= "a" (match-string 1 text1))) | |
447 (Assert (string= "b" (match-string 2 text1))) | |
448 (Assert (null (string-match re0 text2))) | |
449 | |
450 (Check-Error-Message 'invalid-regexp "Invalid back reference" | |
451 (string-match re1 text1)) | |
452 | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
453 (Assert (eq 0 (string-match re2 text1))) |
2542 | 454 (Assert (string= text1 (match-string 0 text1))) |
455 (Assert (string= "b" (match-string 1 text1))) | |
456 (Assert (null (match-string 2 text1))) | |
457 (Assert (null (string-match re2 text2))) | |
458 | |
459 (Assert (null (string-match re3 text1))) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
460 (Assert (eq 0 (string-match re3 text2))) |
2542 | 461 (Assert (string= text2 (match-string 0 text2))) |
462 (Assert (string= "a" (match-string 1 text2))) | |
463 (Assert (null (match-string 2 text2))) | |
464 ) | |
465 | |
4199 | 466 ;; replace-regexp-in-string (regexp rep source |
467 ;; fixedcase literal buf-or-subexp start) | |
468 | |
469 ;; Currently we test the following cases: | |
470 ;; where `cbuf' and `bar-or-empty' are bound below. | |
471 | |
472 ;; #### Tests for the various functional features (fixedcase, literal, start) | |
473 ;; should be added. | |
474 | |
475 (with-temp-buffer | |
476 (flet ((bar-or-empty (subexp) (if (string= subexp "foo") "bar" ""))) | |
477 (let ((cbuf (current-buffer))) | |
478 (dolist (test-case | |
479 ;; REP BUF-OR-SUBEXP EXPECTED RESULT | |
480 `(("bar" nil " bar") | |
481 ("bar" ,cbuf " bar") | |
482 ("bar" 0 " bar") | |
483 ("bar" 1 " bar foo") | |
484 (bar-or-empty nil " ") | |
485 (bar-or-empty ,cbuf " ") | |
486 (bar-or-empty 0 " ") | |
487 (bar-or-empty 1 " bar foo"))) | |
488 (Assert | |
489 (string= | |
490 (nth 2 test-case) | |
491 (replace-regexp-in-string "\\(foo\\).*\\'" (nth 0 test-case) | |
492 " foo foo" nil nil (nth 1 test-case))))) | |
493 ;; #### Why doesn't this loop work right? | |
494 ; (dolist (test-case | |
495 ; ;; REP BUF-OR-SUBEXP EXPECTED ERROR EXPECTED MESSAGE | |
496 ; `(;; expected message was "bufferp, symbol" up to 21.5.28 | |
497 ; ("bar" 'symbol wrong-type-argument "integerp, symbol") | |
498 ; ("bar" -1 invalid-argument | |
499 ; "match data register invalid, -1") | |
500 ; ("bar" 2 invalid-argument | |
501 ; "match data register not set, 2") | |
502 ; )) | |
503 ; (eval | |
504 ; `(Check-Error-Message ,(nth 2 test-case) ,(nth 3 test-case) | |
505 ; (replace-regexp-in-string "\\(foo\\).*\\'" ,(nth 0 test-case) | |
506 ; " foo foo" nil nil ,(nth 1 test-case))))) | |
507 ;; #### Can't test the message with w-t-a, see test-harness.el. | |
508 (Check-Error wrong-type-argument | |
509 (replace-regexp-in-string "\\(foo\\).*\\'" | |
510 "bar" | |
511 " foo foo" nil nil | |
512 'symbol)) | |
513 ;; #### Can't test the FROB (-1), see test-harness.el. | |
514 (Check-Error-Message invalid-argument | |
515 "match data register invalid" | |
516 (replace-regexp-in-string "\\(foo\\).*\\'" | |
517 "bar" | |
518 " foo foo" nil nil | |
519 -1)) | |
520 ;; #### Can't test the FROB (-1), see test-harness.el. | |
521 (Check-Error-Message invalid-argument | |
522 "match data register not set" | |
523 (replace-regexp-in-string "\\(foo\\).*\\'" | |
524 "bar" | |
525 " foo foo" nil nil | |
526 2)) | |
527 ))) | |
528 | |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
529 ;; Not very comprehensive tests of skip-chars-forward, skip-chars-background: |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
530 |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
531 (with-string-as-buffer-contents |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
532 "-]-----------------------------][]]------------------------" |
4517
5e8f6469169f
Fix up initial condition for skip-chars test.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4504
diff
changeset
|
533 (goto-char (point-min)) |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
534 (skip-chars-forward (skip-chars-quote "-[]")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
535 (Assert (= (point) (point-max))) |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
536 (skip-chars-backward (skip-chars-quote "-[]")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
537 (Assert (= (point) (point-min))) |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
538 ;; Testing in passing for an old bug in #'skip-chars-forward where I |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
539 ;; thought it was impossible to call it with a string containing only ?- |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
540 ;; and ?]: |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
541 (Assert (= (skip-chars-forward (skip-chars-quote "-]")) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
542 (position ?[ (buffer-string) :test #'=))) |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
543 ;; This used to error, incorrectly: |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
544 (Assert (skip-chars-quote "[-"))) |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
545 |
4199 | 546 ;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER) |
547 | |
548 ;; #### Write some tests! Much functionality is implicitly tested above | |
549 ;; via `replace-regexp-in-string', but we should specifically test bogus | |
550 ;; combinations of STRING and STRBUFFER. | |
551 | |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
552 ;; empty string at point |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
553 ;; Thanks Julian Bradford on XEmacs Beta |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
554 ;; <18652.54975.894512.880956@krk.inf.ed.ac.uk> |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
555 (with-string-as-buffer-contents "aáa" |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
556 (goto-char (point-min)) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
557 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
558 (Assert (= (re-search-forward "\\=") 1)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
559 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
560 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
561 (Assert (= (re-search-forward "\\=") 2)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
562 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
563 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
564 (Assert (= (re-search-forward "\\=") 3)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
565 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
566 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
567 (Assert (= (re-search-forward "\\=") 4))) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
568 |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
569 |
4897
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
570 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
571 ;; Tests involving case-changing replace-match ;; |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
572 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
573 |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
574 (Assert (not (string-match "\\(\\.\\=\\)" "."))) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
575 (Assert (string= "" (let ((str "test string")) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
576 (if (string-match "^.*$" str) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
577 (replace-match "\\U" t nil str))))) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
578 (with-temp-buffer |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
579 (erase-buffer) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
580 (insert "test string") |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
581 (re-search-backward "^.*$") |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
582 (replace-match "\\U" t) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
583 (Assert (and (bobp) (eobp)))) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
584 |
4900
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
585 ;; Control-1 characters were second-class citizens in regexp ranges |
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
586 ;; for a while there. Addressed in Ben's Mercurial changeset |
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
587 ;; 2e15c29cc2b3; attempt to ensure this doesn't happen again. |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
588 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "a") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
589 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "é") nil)) |
4900
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
590 ;; Gave nil in 21.5 for a couple of years. |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
591 (Assert (eql (string-match "[\x00-\x7f\x80-\x9f]" "\x80") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
592 (Assert (eql (string-match "[\x00-\x7f]\\|[\x80-\x9f]" "\x80") 0)) |
4900
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
593 ;; Gave nil |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
594 (Assert (eql (string-match "[\x7f\x80-\x9f]" "\x80") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
595 (Assert (eql (string-match "[\x80-\x9f]" "\x80") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
596 (Assert (eql (string-match "[\x7f\x80-\x9e]" "\x80") 0)) |
4900
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
597 ;; Used to succeed even with the bug. |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
598 (Assert (eql (string-match "[\x7f\x80\x9f]" "\x80") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
599 (Assert (eql (string-match "[\x7e\x80-\x9f]" "\x80") 0)) |
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
600 (Assert (eql (string-match "[\x7f\x81-\x9f]" "\x81") 0)) |