Mercurial > hg > xemacs-beta
annotate tests/automated/regexp-tests.el @ 5647:1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
2012-04-21 Aidan Kehoe <kehoea@parhasard.net>
* regex.h (RE_SYNTAX_EMACS):
Turn on character classes ([:alnum:] and friends) by default. This
implementation is incomplete, am working on a version that handles
non-ASCII characters correctly.
tests/ChangeLog addition:
2012-04-21 Aidan Kehoe <kehoea@parhasard.net>
* automated/regexp-tests.el:
* automated/regexp-tests.el (Assert-char-class):
Test the character classes functionality that was always in
regex.c but that has only just been turned on. These tests pass on
GNU Emacs 24.0.94.2.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 21 Apr 2012 09:41:27 +0100 |
parents | 308d34e9f07d |
children | 3f4a234f4672 |
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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
13 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
14 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
15 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
16 ;; option) any later version. |
446 | 17 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
18 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
19 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
20 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
21 ;; for more details. |
446 | 22 |
23 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5136
diff
changeset
|
24 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
446 | 25 |
26 ;;; Synched up with: Not in FSF. | |
27 | |
28 ;;; Commentary: | |
29 | |
4897
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
30 ;; Test regular expressions. |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
31 |
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4900
diff
changeset
|
32 ;; 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
|
33 ;; regexp-tests.el and search-tests.el. See case-tests.el. |
446 | 34 |
35 (Check-Error-Message error "Trailing backslash" | |
36 (string-match "\\" "a")) | |
37 (Check-Error-Message error "Invalid preceding regular expression" | |
38 (string-match "a++" "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 "Unmatched \\[ or \\[^" | |
44 (string-match "[" "a")) | |
45 (Check-Error-Message error "Unmatched \\[ or \\[^" | |
46 (string-match "[abc" "a")) | |
47 (Check-Error-Message error "Unmatched ) or \\\\)" | |
48 (string-match "\\)" "a")) | |
49 (Check-Error-Message error "Invalid regular expression" | |
50 (string-match "\\(?.\\)" "a")) | |
51 (Check-Error-Message error "Unmatched \\\\{" | |
52 (string-match "a\\{" "a")) | |
53 (Check-Error-Message error "Invalid content of \\\\{\\\\}" | |
54 (string-match "a\\{a\\}" "a")) | |
55 | |
56 ;; exactn | |
57 | |
58 ;; string-match | |
59 (with-temp-buffer | |
60 ;; case-insensitive | |
61 (Assert (string-match "ä" "ä")) | |
62 (Assert (string-match "ä" "Ä")) | |
63 (Assert (string-match "Ä" "Ä")) | |
64 (Assert (string-match "Ä" "ä")) | |
65 ;; case-sensitive | |
66 (setq case-fold-search nil) | |
67 (Assert (string-match "ä" "ä")) | |
68 (Assert (not (string-match "ä" "Ä"))) | |
69 (Assert (string-match "Ä" "Ä")) | |
70 (Assert (not (string-match "Ä" "ä")))) | |
71 | |
72 ;; looking-at | |
73 (with-temp-buffer | |
74 (insert "äÄ") | |
75 ;; case-insensitive | |
76 (goto-char (point-min)) | |
77 (Assert (looking-at "ä")) | |
78 (Assert (looking-at "Ä")) | |
79 (forward-char) | |
80 (Assert (looking-at "ä")) | |
81 (Assert (looking-at "Ä")) | |
82 ;; case-sensitive | |
83 (setq case-fold-search nil) | |
84 (goto-char (point-min)) | |
85 (Assert (looking-at "ä")) | |
86 (Assert (not (looking-at "Ä"))) | |
87 (forward-char) | |
88 (Assert (not (looking-at "ä"))) | |
89 (Assert (looking-at "Ä"))) | |
90 | |
91 ;; re-search-forward and re-search-backward | |
92 (with-temp-buffer | |
93 (insert "äÄ") | |
94 ;; case insensitive | |
95 ;; forward | |
96 (goto-char (point-min)) | |
97 ;; Avoid trivial regexp. | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
98 (Assert (eq 2 (re-search-forward "ä\\|a" nil t))) |
446 | 99 (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
|
100 (Assert (eq 2 (re-search-forward "Ä\\|a" nil t))) |
446 | 101 (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
|
102 (Assert (eq 3 (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 ;; backward |
106 (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
|
107 (Assert (eq 2 (re-search-backward "ä\\|a" nil t))) |
446 | 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 (1- (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 1 (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 ;; case sensitive |
115 (setq case-fold-search nil) | |
116 ;; forward | |
117 (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
|
118 (Assert (eq 2 (re-search-forward "ä\\|a" nil t))) |
446 | 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 3 (re-search-forward "Ä\\|a" nil t))) |
446 | 121 (goto-char (1+ (point-min))) |
122 (Assert (not (re-search-forward "ä\\|a" nil t))) | |
123 (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
|
124 (Assert (eq 3 (re-search-forward "Ä\\|a" nil t))) |
446 | 125 ;; backward |
126 (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
|
127 (Assert (eq 1 (re-search-backward "ä\\|a" nil t))) |
446 | 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 2 (re-search-backward "Ä\\|a" nil t))) |
446 | 130 (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
|
131 (Assert (eq 1 (re-search-backward "ä\\|a" nil t))) |
446 | 132 (goto-char (1- (point-max))) |
133 (Assert (not (re-search-backward "Ä\\|a" nil t)))) | |
134 | |
135 ;; duplicate | |
136 (with-temp-buffer | |
137 ;; case insensitive | |
138 (Assert (string-match "^\\(ä\\)\\1$" "ää")) | |
139 (Assert (string-match "^\\(ä\\)\\1$" "äÄ")) | |
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 ;; case sensitive | |
147 (setq case-fold-search nil) | |
148 (Assert (string-match "^\\(ä\\)\\1$" "ää")) | |
149 (Assert (not (string-match "^\\(ä\\)\\1$" "äÄ"))) | |
150 (Assert (not (string-match "^\\(ä\\)\\1$" "ÄÄ"))) | |
151 (Assert (not (string-match "^\\(ä\\)\\1$" "Ää"))) | |
152 (Assert (not (string-match "^\\(Ä\\)\\1$" "ää"))) | |
153 (Assert (not (string-match "^\\(Ä\\)\\1$" "äÄ"))) | |
154 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ")) | |
155 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää")))) | |
156 | |
1714 | 157 ;; multiple-match |
158 ;; Thanks to Manfred Bartz <MBartz@xix.com> | |
159 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com> | |
160 ;; #### Need to do repetitions of more complex regexps | |
161 ;; #### WASH ME! | |
162 (with-temp-buffer | |
163 (Assert (not (string-match "^a\\{4,4\\}$" "aaa"))) | |
164 (Assert (string-match "^a\\{4,4\\}$" "aaaa")) | |
165 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa"))) | |
166 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa"))) | |
167 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa")) | |
168 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa"))) | |
169 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa"))) | |
170 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa")) | |
171 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa"))) | |
172 ;; Use class because repetition of single char broken in 21.5.15 | |
173 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa"))) | |
174 (Assert (string-match "^[a]\\{3,5\\}$" "aaa")) | |
175 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa")) | |
176 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa")) | |
177 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa"))) | |
178 (insert "\ | |
179 aa | |
180 aaa | |
181 aaaa | |
182 aaaaa | |
183 aaaaaa | |
184 baaaa | |
185 ") | |
186 (goto-char (point-min)) | |
187 (forward-line 1) | |
188 (Assert (not (looking-at "^a\\{4,4\\}$"))) | |
189 (forward-line 1) | |
190 (Assert (looking-at "^a\\{4,4\\}$")) | |
191 (forward-line 1) | |
192 (Assert (not (looking-at "^a\\{4,4\\}$"))) | |
193 (goto-char (point-min)) | |
194 (forward-line 1) | |
195 (Assert (not (looking-at "^[a]\\{4,4\\}$"))) | |
196 (forward-line 1) | |
197 (Assert (looking-at "^[a]\\{4,4\\}$")) | |
198 (forward-line 1) | |
199 (Assert (not (looking-at "^[a]\\{4,4\\}$"))) | |
200 (goto-char (point-min)) | |
201 (forward-line 1) | |
202 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$"))) | |
203 (forward-line 1) | |
204 (Assert (looking-at "^\\(a\\)\\{4,4\\}$")) | |
205 (forward-line 1) | |
206 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$"))) | |
207 ;; Use class because repetition of single char broken in 21.5.15 | |
208 (goto-char (point-min)) | |
209 (Assert (not (looking-at "^[a]\\{3,5\\}$"))) | |
210 (forward-line 1) | |
211 (Assert (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 (not (looking-at "^[a]\\{3,5\\}$"))) | |
218 (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
|
219 (Assert (= 12 (re-search-forward "a\\{4,4\\}"))) |
1714 | 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 "b?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 (= 31 (re-search-forward "ba\\{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 "[b]a\\{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 (= 12 (re-search-forward "^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 ) |
239 | |
446 | 240 ;; charset, charset_not |
241 ;; Not called because it takes too much time. | |
242 (defun test-regexp-charset-paranoid () | |
243 (let ((i 0) | |
244 (max (expt 2 (if (featurep 'mule) 19 8))) | |
245 (range "[a-z]") | |
246 (range-not "[^a-z]") | |
247 char string) | |
248 (while (< i max) | |
249 (when (setq char (int-to-char i)) | |
250 (setq string (char-to-string char)) | |
251 (if (or (and (<= 65 i) | |
252 (<= i 90)) | |
253 (and (<= 97 i) | |
254 (<= i 122))) | |
255 (progn | |
256 (Assert (string-match range string)) | |
257 (Assert (not (string-match range-not string)))) | |
258 (Assert (not (string-match range string))) | |
259 (Assert (string-match range-not string)))) | |
260 (setq i (1+ i))))) | |
261 | |
262 ;; (test-regexp-charset-paranoid) | |
263 | |
264 ;; charset_mule, charset_mule_not | |
265 ;; Not called because it takes too much time. | |
266 (defun test-regex-charset-mule-paranoid () | |
267 (if (featurep 'mule) | |
268 (let ((i 0) | |
269 (max (expt 2 19)) | |
270 (range (format "[%c-%c]" | |
271 (make-char 'japanese-jisx0208 36 34) | |
272 (make-char 'japanese-jisx0208 36 42))) | |
273 (range-not (format "[^%c-%c]" | |
274 (make-char 'japanese-jisx0208 36 34) | |
275 (make-char 'japanese-jisx0208 36 42))) | |
276 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34))) | |
277 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42))) | |
278 char string) | |
279 (while (< i max) | |
280 (when (setq char (int-to-char i)) | |
281 (setq string (char-to-string char)) | |
282 (if (and (<= min-int i) | |
283 (<= i max-int)) | |
284 (progn | |
285 (Assert (string-match range string)) | |
286 (Assert (not (string-match range-not string)))) | |
287 (Assert (not (string-match range string))) | |
288 (Assert (string-match range-not string)))) | |
289 (setq i (1+ i)))))) | |
290 | |
291 ;; (test-regex-charset-mule-paranoid) | |
448 | 292 |
1472 | 293 ;; Test that replace-match does not clobber registers after a failed match |
448 | 294 (with-temp-buffer |
295 (insert "This is a test buffer.") | |
296 (goto-char (point-min)) | |
297 (search-forward "this is a test ") | |
298 (looking-at "Unmatchable text") | |
1472 | 299 (replace-match "") |
300 (Assert (looking-at "^buffer.$"))) | |
1024 | 301 |
302 ;; Test that trivial regexps reset unused registers | |
303 ;; Thanks to Martin Sternholm for the report. | |
304 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com> | |
305 (with-temp-buffer | |
306 (insert "ab") | |
307 (goto-char (point-min)) | |
308 (re-search-forward "\\(a\\)") | |
1175 | 309 ;; test the whole-match data, too -- one attempted fix scotched that, too! |
1024 | 310 (Assert (string= (match-string 0) "a")) |
311 (Assert (string= (match-string 1) "a")) | |
312 (re-search-forward "b") | |
313 (Assert (string= (match-string 0) "b")) | |
314 (Assert (string= (match-string 1) nil))) | |
315 | |
316 ;; Test word boundaries | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
317 (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
|
318 (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
|
319 (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
|
320 (Assert (= (string-match "a\\b" "a ") 0)) |
1024 | 321 ;; 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
|
322 (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
|
323 (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
|
324 (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
|
325 (Assert (= (string-match "a\\b" "a") 0)) |
1095 | 326 ;; Check for weirdness |
327 (Assert (not (string-match " \\> " " "))) | |
328 (Assert (not (string-match " \\< " " "))) | |
329 (Assert (not (string-match " \\b " " "))) | |
1024 | 330 ;; but not if the "word" would be on the null side of the boundary! |
331 (Assert (not (string-match "\\<" ""))) | |
332 (Assert (not (string-match "\\>" ""))) | |
333 (Assert (not (string-match " \\<" " "))) | |
334 (Assert (not (string-match "\\> " " "))) | |
335 (Assert (not (string-match "a\\<" "a"))) | |
336 (Assert (not (string-match "\\>a" "a"))) | |
1389 | 337 ;; Added Known-Bug 2002-09-09 sjt |
338 ;; Fixed bug 2003-03-21 sjt | |
339 (Assert (not (string-match "\\b" ""))) | |
340 (Assert (not (string-match "\\b" " "))) | |
341 (Assert (not (string-match " \\b" " "))) | |
342 (Assert (not (string-match "\\b " " "))) | |
1175 | 343 |
344 ;; Character classes are broken in Mule as of 21.5.9 | |
345 ;; Added Known-Bug 2002-12-27 | |
1413 | 346 ;; Fixed by Daiki Ueno 2003-03-24 |
1175 | 347 (if (featurep 'mule) |
348 ;; note: (int-to-char 65) => ?A | |
349 (let ((ch0 (make-char 'japanese-jisx0208 52 65)) | |
350 (ch1 (make-char 'japanese-jisx0208 51 65))) | |
351 (Assert (not (string-match "A" (string ch0)))) | |
352 (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
|
353 (Assert (eq (string-match "[^A]" (string ch0)) 0)) |
1175 | 354 (Assert (not (string-match "@A" (string ?@ ch0)))) |
1413 | 355 (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
|
356 (Assert (eq (string-match "@[^A]" (string ?@ ch0)) 0)) |
1175 | 357 (Assert (not (string-match "@?A" (string ?@ ch0)))) |
358 (Assert (not (string-match "A" (string ch1)))) | |
359 (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
|
360 (Assert (eq (string-match "[^A]" (string ch1)) 0)) |
1175 | 361 (Assert (not (string-match "@A" (string ?@ ch1)))) |
362 (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
|
363 (Assert (eq (string-match "@[^A]" (string ?@ ch1)) 0)) |
1413 | 364 (Assert (not (string-match "@?A" (string ?@ ch1)))) |
365 ) | |
366 ) | |
1195 | 367 |
368 ;; More stale match data tests. | |
369 ;; Thanks to <bjacob@ca.metsci.com>. | |
1425 | 370 ;; These tests used to fail because we cleared match data only on success. |
371 ;; Fixed 2003-04-17. | |
1612 | 372 ;; Must change sense of failing tests 2003-05-09. Too much code depends on |
373 ;; failed matches preserving match-data. | |
1472 | 374 (let ((a "a")) |
375 (Assert (string= (progn (string-match "a" a) | |
376 (string-match "b" a) | |
377 (match-string 0 a)) | |
378 a)) | |
379 (Assert (not (progn (string-match "a" a) | |
380 (string-match "b" a) | |
381 (match-string 1 a)))) | |
382 ;; test both for the second match is a plain string match and a regexp match | |
383 (Assert (string= (progn (string-match "\\(a\\)" a) | |
384 (string-match "\\(b\\)" a) | |
385 (match-string 0 a)) | |
386 a)) | |
387 (Assert (string= (progn (string-match "\\(a\\)" a) | |
388 (string-match "b" a) | |
389 (match-string 0 a)) | |
390 a)) | |
391 (Assert (string= (progn (string-match "\\(a\\)" a) | |
392 (string-match "\\(b\\)" a) | |
393 (match-string 1 a)) | |
394 a)) | |
395 (Assert (string= (progn (string-match "\\(a\\)" a) | |
396 (string-match "b" a) | |
397 (match-string 1 a)) | |
2542 | 398 a)) |
399 ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared, | |
400 ;; resulting in stale match data | |
401 (Assert (progn (string-match "\\(a\\)" a) | |
402 (string-match "\\(?:a\\)" a) | |
403 (not (match-beginning 1)))) | |
404 ) | |
2254 | 405 |
406 ;; bug identified by Katsumi Yamaoka 2004-09-03 <b9ywtzbbpue.fsf_-_@jpl.org> | |
407 ;; fix submitted by sjt 2004-09-08 | |
408 ;; trailing comments are values from buggy 21.4.15 | |
409 (let ((text "abc")) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
410 (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
|
411 (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
|
412 (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
|
413 (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
|
414 (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
|
415 (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
|
416 (Assert (eq 0 (string-match "^\\(?:a\\)*b" text))) ; 0 |
2254 | 417 ) |
418 | |
2324 | 419 ;; per Steve Youngs 2004-09-30 <microsoft-free.87ekkjhj7t.fsf@youngs.au.com> |
420 ;; fix submitted by sjt 2004-10-07 | |
421 ;; trailing comments are values from buggy 21.4.pre16 | |
422 (let ((text "abc")) | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
423 (Assert (eq 0 (string-match "\\(?:a\\(b\\)\\)" text))) ; 0 |
2324 | 424 (Assert (string= (match-string 1 text) "b")) ; ab |
425 (Assert (null (match-string 2 text))) ; b | |
426 (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
|
427 (Assert (eq 0 (string-match "\\(?:a\\(?:b\\(c\\)\\)\\)" text))) ; 0 |
2324 | 428 (Assert (string= (match-string 1 text) "c")) ; abc |
429 (Assert (null (match-string 2 text))) ; ab | |
430 (Assert (null (match-string 3 text))) ; c | |
431 (Assert (null (match-string 4 text))) ; nil | |
432 ) | |
433 | |
2542 | 434 ;; trivial subpatterns and backreferences with shy groups |
435 (let ((text1 "abb") | |
436 (text2 "aba") | |
437 (re0 "\\(a\\)\\(b\\)\\2") | |
438 (re1 "\\(?:a\\)\\(b\\)\\2") | |
439 (re2 "\\(?:a\\)\\(b\\)\\1") | |
440 (re3 "\\(a\\)\\(?:b\\)\\1")) | |
441 | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
442 (Assert (eq 0 (string-match re0 text1))) |
2542 | 443 (Assert (string= text1 (match-string 0 text1))) |
444 (Assert (string= "a" (match-string 1 text1))) | |
445 (Assert (string= "b" (match-string 2 text1))) | |
446 (Assert (null (string-match re0 text2))) | |
447 | |
448 (Check-Error-Message 'invalid-regexp "Invalid back reference" | |
449 (string-match re1 text1)) | |
450 | |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
451 (Assert (eq 0 (string-match re2 text1))) |
2542 | 452 (Assert (string= text1 (match-string 0 text1))) |
453 (Assert (string= "b" (match-string 1 text1))) | |
454 (Assert (null (match-string 2 text1))) | |
455 (Assert (null (string-match re2 text2))) | |
456 | |
457 (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
|
458 (Assert (eq 0 (string-match re3 text2))) |
2542 | 459 (Assert (string= text2 (match-string 0 text2))) |
460 (Assert (string= "a" (match-string 1 text2))) | |
461 (Assert (null (match-string 2 text2))) | |
462 ) | |
463 | |
4199 | 464 ;; replace-regexp-in-string (regexp rep source |
465 ;; fixedcase literal buf-or-subexp start) | |
466 | |
467 ;; Currently we test the following cases: | |
468 ;; where `cbuf' and `bar-or-empty' are bound below. | |
469 | |
470 ;; #### Tests for the various functional features (fixedcase, literal, start) | |
471 ;; should be added. | |
472 | |
473 (with-temp-buffer | |
474 (flet ((bar-or-empty (subexp) (if (string= subexp "foo") "bar" ""))) | |
475 (let ((cbuf (current-buffer))) | |
476 (dolist (test-case | |
477 ;; REP BUF-OR-SUBEXP EXPECTED RESULT | |
478 `(("bar" nil " bar") | |
479 ("bar" ,cbuf " bar") | |
480 ("bar" 0 " bar") | |
481 ("bar" 1 " bar foo") | |
482 (bar-or-empty nil " ") | |
483 (bar-or-empty ,cbuf " ") | |
484 (bar-or-empty 0 " ") | |
485 (bar-or-empty 1 " bar foo"))) | |
486 (Assert | |
487 (string= | |
488 (nth 2 test-case) | |
489 (replace-regexp-in-string "\\(foo\\).*\\'" (nth 0 test-case) | |
490 " foo foo" nil nil (nth 1 test-case))))) | |
491 ;; #### Why doesn't this loop work right? | |
492 ; (dolist (test-case | |
493 ; ;; REP BUF-OR-SUBEXP EXPECTED ERROR EXPECTED MESSAGE | |
494 ; `(;; expected message was "bufferp, symbol" up to 21.5.28 | |
495 ; ("bar" 'symbol wrong-type-argument "integerp, symbol") | |
496 ; ("bar" -1 invalid-argument | |
497 ; "match data register invalid, -1") | |
498 ; ("bar" 2 invalid-argument | |
499 ; "match data register not set, 2") | |
500 ; )) | |
501 ; (eval | |
502 ; `(Check-Error-Message ,(nth 2 test-case) ,(nth 3 test-case) | |
503 ; (replace-regexp-in-string "\\(foo\\).*\\'" ,(nth 0 test-case) | |
504 ; " foo foo" nil nil ,(nth 1 test-case))))) | |
505 ;; #### Can't test the message with w-t-a, see test-harness.el. | |
506 (Check-Error wrong-type-argument | |
507 (replace-regexp-in-string "\\(foo\\).*\\'" | |
508 "bar" | |
509 " foo foo" nil nil | |
510 'symbol)) | |
511 ;; #### Can't test the FROB (-1), see test-harness.el. | |
512 (Check-Error-Message invalid-argument | |
513 "match data register invalid" | |
514 (replace-regexp-in-string "\\(foo\\).*\\'" | |
515 "bar" | |
516 " foo foo" nil nil | |
517 -1)) | |
518 ;; #### Can't test the FROB (-1), see test-harness.el. | |
519 (Check-Error-Message invalid-argument | |
520 "match data register not set" | |
521 (replace-regexp-in-string "\\(foo\\).*\\'" | |
522 "bar" | |
523 " foo foo" nil nil | |
524 2)) | |
525 ))) | |
526 | |
4504
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
527 ;; 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
|
528 |
b82fdf7305ee
Correct the implementation, add a few basic tests for #'skip-chars-quote.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4199
diff
changeset
|
529 (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
|
530 "-]-----------------------------][]]------------------------" |
4517
5e8f6469169f
Fix up initial condition for skip-chars test.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4504
diff
changeset
|
531 (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
|
532 (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
|
533 (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
|
534 (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
|
535 (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
|
536 ;; 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
|
537 ;; 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
|
538 ;; and ?]: |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
539 (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
|
540 (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
|
541 ;; 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
|
542 (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
|
543 |
4199 | 544 ;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER) |
545 | |
546 ;; #### Write some tests! Much functionality is implicitly tested above | |
547 ;; via `replace-regexp-in-string', but we should specifically test bogus | |
548 ;; combinations of STRING and STRBUFFER. | |
549 | |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
550 ;; empty string at point |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
551 ;; Thanks Julian Bradford on XEmacs Beta |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
552 ;; <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
|
553 (with-string-as-buffer-contents "aáa" |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
554 (goto-char (point-min)) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
555 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
556 (Assert (= (re-search-forward "\\=") 1)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
557 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
558 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
559 (Assert (= (re-search-forward "\\=") 2)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
560 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
561 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
562 (Assert (= (re-search-forward "\\=") 3)) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
563 (forward-char 1) |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
564 (Assert (looking-at "\\=")) |
5136
0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents:
4906
diff
changeset
|
565 (Assert (= (re-search-forward "\\=") 4))) |
4518
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
566 |
e0a8c796f955
Add test for at_dot regexp.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4517
diff
changeset
|
567 |
4897
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
568 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
569 ;; 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
|
570 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
571 |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
572 (Assert (not (string-match "\\(\\.\\=\\)" "."))) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
573 (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
|
574 (if (string-match "^.*$" str) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
575 (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
|
576 (with-temp-buffer |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
577 (erase-buffer) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
578 (insert "test string") |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
579 (re-search-backward "^.*$") |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
580 (replace-match "\\U" t) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
581 (Assert (and (bobp) (eobp)))) |
91a023144e72
fix longstanding search bug involving searching for Control-1 chars
Ben Wing <ben@xemacs.org>
parents:
4855
diff
changeset
|
582 |
4900
0eccfd4850d6
Add tests for the regexp-ranges-treat-control-1-chars badly bug.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4897
diff
changeset
|
583 ;; 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
|
584 ;; 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
|
585 ;; 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
|
586 (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
|
587 (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
|
588 ;; 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
|
589 (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
|
590 (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
|
591 ;; Gave nil |
5136
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 "[\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
|
593 (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
|
594 (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
|
595 ;; 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
|
596 (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
|
597 (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
|
598 (Assert (eql (string-match "[\x7f\x81-\x9f]" "\x81") 0)) |
5647
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
599 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
600 ;; Test character classes |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
601 (macrolet |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
602 ((Assert-char-class (class matching-char non-matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
603 (if (and (not (featurep 'mule)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
604 (or (eq (car-safe matching-char) 'decode-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
605 (eq (car-safe non-matching-char) 'decode-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
606 ;; Don't attempt expansion if these clauses require Mule and we |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
607 ;; don't have it. |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
608 (return-from Assert-char-class nil) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
609 (setq matching-char (eval matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
610 non-matching-char (eval non-matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
611 `(progn |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
612 (Assert (eql (string-match ,(concat "[" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
613 ,(concat (string matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
614 (string non-matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
615 0)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
616 (Assert (eql (string-match ,(concat "[" class class class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
617 ,(concat (string matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
618 (string non-matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
619 0)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
620 (Assert (eql (string-match ,(concat "[^" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
621 ,(concat (string non-matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
622 (string matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
623 0)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
624 (Assert (eql (string-match ,(concat "[^" class class class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
625 ,(concat (string non-matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
626 (string matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
627 0)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
628 (Assert (eql (string-match ,(concat "[" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
629 ,(concat (string non-matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
630 (string matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
631 1)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
632 (Assert (eql (string-match ,(concat "[" class class class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
633 ,(concat (string non-matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
634 (string matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
635 1)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
636 (Assert (eql (string-match ,(concat "[^" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
637 ,(concat (string matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
638 (string non-matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
639 1)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
640 (Assert (eql (string-match ,(concat "[^" class class class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
641 ,(concat (string matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
642 (string non-matching-char))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
643 1)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
644 (Assert (null (string-match ,(concat "[" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
645 ,(string non-matching-char)))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
646 (Assert (null (string-match ,(concat "[^" class "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
647 ,(string matching-char)))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
648 (Assert (null (string-match ,(concat "[^" class |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
649 (string non-matching-char) "]") |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
650 ,(concat (string matching-char) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
651 (string non-matching-char)))))))) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
652 (Assert-char-class "[:alpha:]" ?a ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
653 (Assert-char-class "[:alpha:]" ?z ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
654 (Assert-char-class "[:alpha:]" ?A ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
655 (Assert-char-class "[:alpha:]" ?Z ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
656 (Assert-char-class "[:alpha:]" ?b ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
657 (Assert-char-class "[:alpha:]" ?c ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
658 (Assert-char-class "[:alpha:]" ?d ?\ ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
659 (Assert-char-class "[:alpha:]" ?e ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
660 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
661 (Assert-char-class "[:alnum:]" ?a ?.) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
662 (Assert-char-class "[:alnum:]" ?z ?') |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
663 (Assert-char-class "[:alnum:]" ?A ?/) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
664 (Assert-char-class "[:alnum:]" ?Z ?!) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
665 (Assert-char-class "[:alnum:]" ?0 ?,) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
666 (Assert-char-class "[:alnum:]" ?9 ?$) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
667 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
668 (Assert-char-class "[:alnum:]" ?b ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
669 (Assert-char-class "[:alnum:]" ?c ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
670 (Assert-char-class "[:alnum:]" ?d ?\ ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
671 (Assert-char-class "[:alnum:]" ?e ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
672 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
673 (let ((case-fold-search nil)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
674 (Assert-char-class "[:upper:]" ?A ?a) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
675 (Assert-char-class "[:upper:]" ?Z ?z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
676 (Assert-char-class "[:upper:]" ?B ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
677 (Assert-char-class "[:upper:]" ?C ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
678 (Assert-char-class "[:upper:]" ?D ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
679 (Assert-char-class "[:upper:]" ?E ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
680 (Assert-char-class "[:upper:]" ?F ?\ ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
681 (Assert-char-class "[:upper:]" ?G ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
682 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
683 (Assert-char-class "[:lower:]" ?a ?A) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
684 (Assert-char-class "[:lower:]" ?z ?Z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
685 (Assert-char-class "[:lower:]" ?b ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
686 (Assert-char-class "[:lower:]" ?c ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
687 (Assert-char-class "[:lower:]" ?d ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
688 (Assert-char-class "[:lower:]" ?e ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
689 (Assert-char-class "[:lower:]" ?f ? ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
690 (Assert-char-class "[:lower:]" ?g ?\x7f)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
691 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
692 (let ((case-fold-search t)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
693 ;; These currently fail, because we don't take into account the buffer's |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
694 ;; case table. |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
695 (Assert-char-class "[:upper:]" ?a ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
696 (Assert-char-class "[:upper:]" ?z ?\x01) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
697 (Assert-char-class "[:upper:]" ?b ?{) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
698 (Assert-char-class "[:upper:]" ?c ?}) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
699 (Assert-char-class "[:upper:]" ?d ?<) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
700 (Assert-char-class "[:upper:]" ?e ?>) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
701 (Assert-char-class "[:upper:]" ?f ?\ ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
702 (Assert-char-class "[:upper:]" ?g ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
703 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
704 (Assert-char-class "[:lower:]" ?A ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
705 (Assert-char-class "[:lower:]" ?Z ?\x01) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
706 (Assert-char-class "[:lower:]" ?B ?{) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
707 (Assert-char-class "[:lower:]" ?C ?}) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
708 (Assert-char-class "[:lower:]" ?D ?<) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
709 (Assert-char-class "[:lower:]" ?E ?>) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
710 (Assert-char-class "[:lower:]" ?F ?\ ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
711 (Assert-char-class "[:lower:]" ?G ?\x7F)) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
712 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
713 (Assert-char-class "[:digit:]" ?0 ?a) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
714 (Assert-char-class "[:digit:]" ?9 ?z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
715 (Assert-char-class "[:digit:]" ?1 ?A) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
716 (Assert-char-class "[:digit:]" ?2 ?Z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
717 (Assert-char-class "[:digit:]" ?3 ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
718 (Assert-char-class "[:digit:]" ?4 ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
719 (Assert-char-class "[:digit:]" ?5 ? ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
720 (Assert-char-class "[:digit:]" ?6 ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
721 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
722 (Assert-char-class "[:xdigit:]" ?0 ?g) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
723 (Assert-char-class "[:xdigit:]" ?9 ?G) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
724 (Assert-char-class "[:xdigit:]" ?A ?{) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
725 (Assert-char-class "[:xdigit:]" ?a ?}) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
726 (Assert-char-class "[:xdigit:]" ?1 ? ) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
727 (Assert-char-class "[:xdigit:]" ?2 ?Z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
728 (Assert-char-class "[:xdigit:]" ?3 ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
729 (Assert-char-class "[:xdigit:]" ?4 ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
730 (Assert-char-class "[:xdigit:]" ?5 ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
731 (Assert-char-class "[:xdigit:]" ?6 ?z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
732 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
733 (Assert-char-class "[:space:]" ?\ ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
734 (Assert-char-class "[:space:]" ?\t ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
735 (Assert-char-class "[:space:]" ?\ ?A) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
736 (Assert-char-class "[:space:]" ?\t ?Z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
737 (Assert-char-class "[:space:]" ?\ ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
738 (Assert-char-class "[:space:]" ?\ ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
739 (Assert-char-class "[:space:]" ?\t ?a) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
740 (Assert-char-class "[:space:]" ?\ ?z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
741 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
742 (Assert-char-class "[:print:]" ?\ ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
743 (Assert-char-class "[:print:]" ?0 ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
744 (Assert-char-class "[:print:]" ?9 ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
745 (Assert-char-class "[:print:]" ?A ?\x01) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
746 (Assert-char-class "[:print:]" ?Z ?\x02) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
747 (Assert-char-class "[:print:]" ?B ?\t) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
748 (Assert-char-class "[:print:]" ?a ?\x03) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
749 (Assert-char-class "[:print:]" ?z ?\x04) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
750 |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
751 (Assert-char-class "[:punct:]" ?\( ?0) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
752 (Assert-char-class "[:punct:]" ?. ?9) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
753 (Assert-char-class "[:punct:]" ?{ ?A) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
754 (Assert-char-class "[:punct:]" ?} ?Z) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
755 (Assert-char-class "[:punct:]" ?: ?\t) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
756 (Assert-char-class "[:punct:]" ?\; ?\x00) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
757 (Assert-char-class "[:punct:]" ?< ?\x09) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
758 (Assert-char-class "[:punct:]" ?> ?\x7f) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
759 (Assert-char-class "[:punct:]" ?= ?a) |
1d9f603e9125
Turn on character classes in regex.c by default; test them in regexp-tests.el
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
760 (Assert-char-class "[:punct:]" ?\? ?z)) |