annotate tests/automated/regexp-tests.el @ 5576:071b810ceb18

Declare labels as line where appropriate; use #'labels, not #'flet, tests. lisp/ChangeLog addition: 2011-10-03 Aidan Kehoe <kehoea@parhasard.net> * simple.el (handle-pre-motion-command-current-command-is-motion): Implement #'keysyms-equal with #'labels + (declare (inline ...)), instead of abusing macrolet to the same end. * specifier.el (let-specifier): * mule/mule-cmds.el (describe-language-environment): * mule/mule-cmds.el (set-language-environment-coding-systems): * mule/mule-x-init.el (x-use-halfwidth-roman-font): * faces.el (Face-frob-property): * keymap.el (key-sequence-list-description): * lisp-mode.el (construct-lisp-mode-menu): * loadhist.el (unload-feature): * mouse.el (default-mouse-track-check-for-activation): Declare various labels inline in dumped files when that reduces the size of the dumped image. Declaring labels inline is normally only worthwhile for inner loops and so on, but it's reasonable exercise of the related code to have these changes in core. tests/ChangeLog addition: 2011-10-03 Aidan Kehoe <kehoea@parhasard.net> * automated/case-tests.el (uni-mappings): * automated/database-tests.el (delete-database-files): * automated/hash-table-tests.el (iterations): * automated/lisp-tests.el (test1): * automated/lisp-tests.el (a): * automated/lisp-tests.el (cl-floor): * automated/lisp-tests.el (foo): * automated/lisp-tests.el (list-nreverse): * automated/lisp-tests.el (needs-lexical-context): * automated/mule-tests.el (featurep): * automated/os-tests.el (original-string): * automated/os-tests.el (with): * automated/symbol-tests.el (check-weak-list-unique): Replace #'flet with #'labels where appropriate in these tests, following my own advice on style in the docstrings of those functions.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 03 Oct 2011 20:16:14 +0100
parents 308d34e9f07d
children 1d9f603e9125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
1 ;;; -*- coding: iso-8859-1 -*-
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
2
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
3 ;; Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
5
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
6 ;; Author: Yoshiki Hayashi <yoshiki@xemacs.org>
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
7 ;; Maintainer: Stephen J. Turnbull <stephen@xemacs.org>
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
8 ;; Created: 2000
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
9 ;; Keywords: tests
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
10
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
22
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
25
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
27
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
28 ;;; Commentary:
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
34
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
35 (Check-Error-Message error "Trailing backslash"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
36 (string-match "\\" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
37 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
38 (string-match "a++" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
39 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
40 (string-match "a**" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
41 (Check-Error-Message error "Invalid preceding regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
42 (string-match "a???" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
43 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
44 (string-match "[" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
45 (Check-Error-Message error "Unmatched \\[ or \\[^"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
46 (string-match "[abc" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
47 (Check-Error-Message error "Unmatched ) or \\\\)"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
48 (string-match "\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
49 (Check-Error-Message error "Invalid regular expression"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
50 (string-match "\\(?.\\)" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
51 (Check-Error-Message error "Unmatched \\\\{"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
52 (string-match "a\\{" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
53 (Check-Error-Message error "Invalid content of \\\\{\\\\}"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
54 (string-match "a\\{a\\}" "a"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
55
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
56 ;; exactn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
57
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
58 ;; string-match
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
59 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
60 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
61 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
62 (Assert (string-match "ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
63 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
64 (Assert (string-match "Ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
65 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
66 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
67 (Assert (string-match "ä" "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
68 (Assert (not (string-match "ä" "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
69 (Assert (string-match "Ä" "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
70 (Assert (not (string-match "Ä" "ä"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
71
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
72 ;; looking-at
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
73 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
74 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
75 ;; case-insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
76 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
77 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
78 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
79 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
80 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
81 (Assert (looking-at "Ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
82 ;; case-sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
83 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
84 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
85 (Assert (looking-at "ä"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
86 (Assert (not (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
87 (forward-char)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
88 (Assert (not (looking-at "ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
89 (Assert (looking-at "Ä")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
90
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
91 ;; re-search-forward and re-search-backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
92 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
93 (insert "äÄ")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
94 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
95 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
96 (goto-char (point-min))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
105 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
114 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
115 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
116 ;; forward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
121 (goto-char (1+ (point-min)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
122 (Assert (not (re-search-forward "ä\\|a" nil t)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
125 ;; backward
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
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
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
132 (goto-char (1- (point-max)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
133 (Assert (not (re-search-backward "Ä\\|a" nil t))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
134
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
135 ;; duplicate
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
136 (with-temp-buffer
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
137 ;; case insensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
138 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
139 (Assert (string-match "^\\(ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
140 (Assert (string-match "^\\(ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
141 (Assert (string-match "^\\(ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
142 (Assert (string-match "^\\(Ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
143 (Assert (string-match "^\\(Ä\\)\\1$" "äÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
144 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
145 (Assert (string-match "^\\(Ä\\)\\1$" "Ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
146 ;; case sensitive
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
147 (setq case-fold-search nil)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
148 (Assert (string-match "^\\(ä\\)\\1$" "ää"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
149 (Assert (not (string-match "^\\(ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
150 (Assert (not (string-match "^\\(ä\\)\\1$" "ÄÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
151 (Assert (not (string-match "^\\(ä\\)\\1$" "Ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
152 (Assert (not (string-match "^\\(Ä\\)\\1$" "ää")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
153 (Assert (not (string-match "^\\(Ä\\)\\1$" "äÄ")))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
154 (Assert (string-match "^\\(Ä\\)\\1$" "ÄÄ"))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
155 (Assert (not (string-match "^\\(Ä\\)\\1$" "Ää"))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
156
1714
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
157 ;; multiple-match
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
158 ;; Thanks to Manfred Bartz <MBartz@xix.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
159 ;; c.e.x <vn4rkkm7ouf3b5@corp.supernews.com>
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
160 ;; #### Need to do repetitions of more complex regexps
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
161 ;; #### WASH ME!
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
162 (with-temp-buffer
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
163 (Assert (not (string-match "^a\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
164 (Assert (string-match "^a\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
165 (Assert (not (string-match "^a\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
166 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
167 (Assert (string-match "^[a]\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
168 (Assert (not (string-match "^[a]\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
169 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
170 (Assert (string-match "^\\(a\\)\\{4,4\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
171 (Assert (not (string-match "^\\(a\\)\\{4,4\\}$" "aaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
172 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
173 (Assert (not (string-match "^[a]\\{3,5\\}$" "aa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
174 (Assert (string-match "^[a]\\{3,5\\}$" "aaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
175 (Assert (string-match "^[a]\\{3,5\\}$" "aaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
176 (Assert (string-match "^[a]\\{3,5\\}$" "aaaaa"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
177 (Assert (not (string-match "^[a]\\{3,5\\}$" "aaaaaa")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
178 (insert "\
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
179 aa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
180 aaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
181 aaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
182 aaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
183 aaaaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
184 baaaa
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
185 ")
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
186 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
187 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
188 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
189 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
190 (Assert (looking-at "^a\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
191 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
192 (Assert (not (looking-at "^a\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
193 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
194 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
195 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
196 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
197 (Assert (looking-at "^[a]\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
198 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
199 (Assert (not (looking-at "^[a]\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
200 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
201 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
202 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
203 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
204 (Assert (looking-at "^\\(a\\)\\{4,4\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
205 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
206 (Assert (not (looking-at "^\\(a\\)\\{4,4\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
207 ;; Use class because repetition of single char broken in 21.5.15
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
208 (goto-char (point-min))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
209 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
210 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
211 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
212 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
213 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
214 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
215 (Assert (looking-at "^[a]\\{3,5\\}$"))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
216 (forward-line 1)
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
217 (Assert (not (looking-at "^[a]\\{3,5\\}$")))
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
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
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
238 )
61179c12fbb7 [xemacs-hg @ 2003-09-25 11:59:20 by stephent]
stephent
parents: 1612
diff changeset
239
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
240 ;; charset, charset_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
241 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
242 (defun test-regexp-charset-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
243 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
244 (max (expt 2 (if (featurep 'mule) 19 8)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
245 (range "[a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
246 (range-not "[^a-z]")
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
247 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
248 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
249 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
250 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
251 (if (or (and (<= 65 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
252 (<= i 90))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
253 (and (<= 97 i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
254 (<= i 122)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
255 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
256 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
257 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
258 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
259 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
260 (setq i (1+ i)))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
261
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
262 ;; (test-regexp-charset-paranoid)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
263
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
264 ;; charset_mule, charset_mule_not
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
265 ;; Not called because it takes too much time.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
266 (defun test-regex-charset-mule-paranoid ()
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
267 (if (featurep 'mule)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
268 (let ((i 0)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
269 (max (expt 2 19))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
270 (range (format "[%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
271 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
272 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
273 (range-not (format "[^%c-%c]"
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
274 (make-char 'japanese-jisx0208 36 34)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
275 (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
276 (min-int (char-to-int (make-char 'japanese-jisx0208 36 34)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
277 (max-int (char-to-int (make-char 'japanese-jisx0208 36 42)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
278 char string)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
279 (while (< i max)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
280 (when (setq char (int-to-char i))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
281 (setq string (char-to-string char))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
282 (if (and (<= min-int i)
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
283 (<= i max-int))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
284 (progn
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
285 (Assert (string-match range string))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
286 (Assert (not (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
287 (Assert (not (string-match range string)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
288 (Assert (string-match range-not string))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
289 (setq i (1+ i))))))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
290
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents:
diff changeset
291 ;; (test-regex-charset-mule-paranoid)
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
292
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
293 ;; Test that replace-match does not clobber registers after a failed match
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
294 (with-temp-buffer
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
295 (insert "This is a test buffer.")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
296 (goto-char (point-min))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
297 (search-forward "this is a test ")
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
298 (looking-at "Unmatchable text")
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
299 (replace-match "")
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
300 (Assert (looking-at "^buffer.$")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
301
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
302 ;; Test that trivial regexps reset unused registers
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
303 ;; Thanks to Martin Sternholm for the report.
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
304 ;; xemacs-beta <5blm6h2ki5.fsf@lister.roxen.com>
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
305 (with-temp-buffer
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
306 (insert "ab")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
307 (goto-char (point-min))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
308 (re-search-forward "\\(a\\)")
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
309 ;; test the whole-match data, too -- one attempted fix scotched that, too!
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
310 (Assert (string= (match-string 0) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
311 (Assert (string= (match-string 1) "a"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
312 (re-search-forward "b")
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
313 (Assert (string= (match-string 0) "b"))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
314 (Assert (string= (match-string 1) nil)))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
315
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
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
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
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
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
326 ;; Check for weirdness
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
327 (Assert (not (string-match " \\> " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
328 (Assert (not (string-match " \\< " " ")))
0d33547d9ed3 [xemacs-hg @ 2002-11-11 15:39:03 by stephent]
stephent
parents: 1024
diff changeset
329 (Assert (not (string-match " \\b " " ")))
1024
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
330 ;; but not if the "word" would be on the null side of the boundary!
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
331 (Assert (not (string-match "\\<" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
332 (Assert (not (string-match "\\>" "")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
333 (Assert (not (string-match " \\<" " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
334 (Assert (not (string-match "\\> " " ")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
335 (Assert (not (string-match "a\\<" "a")))
ccaf90c5a53a [xemacs-hg @ 2002-10-02 09:29:37 by stephent]
stephent
parents: 448
diff changeset
336 (Assert (not (string-match "\\>a" "a")))
1389
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
337 ;; Added Known-Bug 2002-09-09 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
338 ;; Fixed bug 2003-03-21 sjt
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
339 (Assert (not (string-match "\\b" "")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
340 (Assert (not (string-match "\\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
341 (Assert (not (string-match " \\b" " ")))
6355bae896e3 [xemacs-hg @ 2003-03-27 12:57:36 by stephent]
stephent
parents: 1195
diff changeset
342 (Assert (not (string-match "\\b " " ")))
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
343
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
344 ;; Character classes are broken in Mule as of 21.5.9
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
345 ;; Added Known-Bug 2002-12-27
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
346 ;; Fixed by Daiki Ueno 2003-03-24
1175
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
347 (if (featurep 'mule)
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
348 ;; note: (int-to-char 65) => ?A
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
349 (let ((ch0 (make-char 'japanese-jisx0208 52 65))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
350 (ch1 (make-char 'japanese-jisx0208 51 65)))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
351 (Assert (not (string-match "A" (string ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
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
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
354 (Assert (not (string-match "@A" (string ?@ ch0))))
1413
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
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
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
357 (Assert (not (string-match "@?A" (string ?@ ch0))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
358 (Assert (not (string-match "A" (string ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
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
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
361 (Assert (not (string-match "@A" (string ?@ ch1))))
2af1f88a2d31 [xemacs-hg @ 2002-12-27 06:13:13 by stephent]
stephent
parents: 1095
diff changeset
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
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
364 (Assert (not (string-match "@?A" (string ?@ ch1))))
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
365 )
aa15a2bbba1a [xemacs-hg @ 2003-04-15 15:56:56 by stephent]
stephent
parents: 1389
diff changeset
366 )
1195
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
367
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
368 ;; More stale match data tests.
dff007bd492b [xemacs-hg @ 2003-01-09 12:49:36 by stephent]
stephent
parents: 1175
diff changeset
369 ;; Thanks to <bjacob@ca.metsci.com>.
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
370 ;; These tests used to fail because we cleared match data only on success.
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 1413
diff changeset
371 ;; Fixed 2003-04-17.
1612
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
372 ;; Must change sense of failing tests 2003-05-09. Too much code depends on
28ffd53a1d42 [xemacs-hg @ 2003-08-11 10:03:34 by stephent]
stephent
parents: 1472
diff changeset
373 ;; failed matches preserving match-data.
1472
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
374 (let ((a "a"))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
375 (Assert (string= (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
376 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
377 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
378 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
379 (Assert (not (progn (string-match "a" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
380 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
381 (match-string 1 a))))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
382 ;; test both for the second match is a plain string match and a regexp match
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
383 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
384 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
385 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
386 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
387 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
388 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
389 (match-string 0 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
390 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
391 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
392 (string-match "\\(b\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
393 (match-string 1 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
394 a))
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
395 (Assert (string= (progn (string-match "\\(a\\)" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
396 (string-match "b" a)
4c87ece1e837 [xemacs-hg @ 2003-05-10 07:44:22 by stephent]
stephent
parents: 1425
diff changeset
397 (match-string 1 a))
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
398 a))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
399 ;; in 21.4.16, registers from num_shy_groups to num_groups were not cleared,
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
400 ;; resulting in stale match data
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
401 (Assert (progn (string-match "\\(a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
402 (string-match "\\(?:a\\)" a)
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
403 (not (match-beginning 1))))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
404 )
2254
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
405
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
406 ;; bug identified by Katsumi Yamaoka 2004-09-03 <b9ywtzbbpue.fsf_-_@jpl.org>
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
407 ;; fix submitted by sjt 2004-09-08
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
408 ;; trailing comments are values from buggy 21.4.15
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
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
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
417 )
cf4470caf504 [xemacs-hg @ 2004-09-08 10:21:57 by stephent]
stephent
parents: 1714
diff changeset
418
2324
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
419 ;; per Steve Youngs 2004-09-30 <microsoft-free.87ekkjhj7t.fsf@youngs.au.com>
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
420 ;; fix submitted by sjt 2004-10-07
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
421 ;; trailing comments are values from buggy 21.4.pre16
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
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
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
424 (Assert (string= (match-string 1 text) "b")) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
425 (Assert (null (match-string 2 text))) ; b
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
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
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
428 (Assert (string= (match-string 1 text) "c")) ; abc
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
429 (Assert (null (match-string 2 text))) ; ab
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
430 (Assert (null (match-string 3 text))) ; c
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
431 (Assert (null (match-string 4 text))) ; nil
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
432 )
df2fafa399a1 [xemacs-hg @ 2004-10-07 08:01:41 by stephent]
stephent
parents: 2254
diff changeset
433
2542
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
434 ;; trivial subpatterns and backreferences with shy groups
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
435 (let ((text1 "abb")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
436 (text2 "aba")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
437 (re0 "\\(a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
438 (re1 "\\(?:a\\)\\(b\\)\\2")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
439 (re2 "\\(?:a\\)\\(b\\)\\1")
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
440 (re3 "\\(a\\)\\(?:b\\)\\1"))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
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
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
443 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
444 (Assert (string= "a" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
445 (Assert (string= "b" (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
446 (Assert (null (string-match re0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
447
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
448 (Check-Error-Message 'invalid-regexp "Invalid back reference"
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
449 (string-match re1 text1))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
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
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
452 (Assert (string= text1 (match-string 0 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
453 (Assert (string= "b" (match-string 1 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
454 (Assert (null (match-string 2 text1)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
455 (Assert (null (string-match re2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
456
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
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
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
459 (Assert (string= text2 (match-string 0 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
460 (Assert (string= "a" (match-string 1 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
461 (Assert (null (match-string 2 text2)))
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
462 )
60989130c706 [xemacs-hg @ 2005-02-02 11:37:18 by stephent]
stephent
parents: 2324
diff changeset
463
4199
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
464 ;; replace-regexp-in-string (regexp rep source
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
465 ;; fixedcase literal buf-or-subexp start)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
466
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
467 ;; Currently we test the following cases:
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
468 ;; where `cbuf' and `bar-or-empty' are bound below.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
469
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
470 ;; #### Tests for the various functional features (fixedcase, literal, start)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
471 ;; should be added.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
472
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
473 (with-temp-buffer
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
474 (flet ((bar-or-empty (subexp) (if (string= subexp "foo") "bar" "")))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
475 (let ((cbuf (current-buffer)))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
476 (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
477 ;; REP BUF-OR-SUBEXP EXPECTED RESULT
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
478 `(("bar" nil " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
479 ("bar" ,cbuf " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
480 ("bar" 0 " bar")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
481 ("bar" 1 " bar foo")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
482 (bar-or-empty nil " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
483 (bar-or-empty ,cbuf " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
484 (bar-or-empty 0 " ")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
485 (bar-or-empty 1 " bar foo")))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
486 (Assert
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
487 (string=
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
488 (nth 2 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
489 (replace-regexp-in-string "\\(foo\\).*\\'" (nth 0 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
490 " foo foo" nil nil (nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
491 ;; #### Why doesn't this loop work right?
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
492 ; (dolist (test-case
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
493 ; ;; REP BUF-OR-SUBEXP EXPECTED ERROR EXPECTED MESSAGE
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
494 ; `(;; expected message was "bufferp, symbol" up to 21.5.28
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
495 ; ("bar" 'symbol wrong-type-argument "integerp, symbol")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
496 ; ("bar" -1 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
497 ; "match data register invalid, -1")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
498 ; ("bar" 2 invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
499 ; "match data register not set, 2")
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
500 ; ))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
501 ; (eval
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
502 ; `(Check-Error-Message ,(nth 2 test-case) ,(nth 3 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
503 ; (replace-regexp-in-string "\\(foo\\).*\\'" ,(nth 0 test-case)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
504 ; " foo foo" nil nil ,(nth 1 test-case)))))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
505 ;; #### Can't test the message with w-t-a, see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
506 (Check-Error wrong-type-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
507 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
508 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
509 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
510 'symbol))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
511 ;; #### Can't test the FROB (-1), see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
512 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
513 "match data register invalid"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
514 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
515 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
516 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
517 -1))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
518 ;; #### Can't test the FROB (-1), see test-harness.el.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
519 (Check-Error-Message invalid-argument
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
520 "match data register not set"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
521 (replace-regexp-in-string "\\(foo\\).*\\'"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
522 "bar"
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
523 " foo foo" nil nil
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
524 2))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
525 )))
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
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
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
544 ;; replace-match (REPLACEMENT &optional FIXEDCASE LITERAL STRING STRBUFFER)
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
545
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
546 ;; #### Write some tests! Much functionality is implicitly tested above
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
547 ;; via `replace-regexp-in-string', but we should specifically test bogus
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
548 ;; combinations of STRING and STRBUFFER.
3660d327399f [xemacs-hg @ 2007-10-01 08:07:39 by stephent]
stephent
parents: 2542
diff changeset
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))