Mercurial > hg > xemacs-beta
comparison tests/automated/search-tests.el @ 5136:0f66906b6e37
Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
-------------------- ChangeLog entries follow: --------------------
lisp/ChangeLog addition:
2010-03-12 Ben Wing <ben@xemacs.org>
* test-harness.el (test-harness-from-buffer):
Undo change of e.g. (Assert (equalp ...)) to (Assert-equalp ...).
Get rid of `Assert-equalp' and friends, `Assert-test', and
`Assert-test-not'. Instead, make `Assert' smart enough to do the
equivalent functionality when an expression like (Assert (equalp ...))
is seen.
tests/ChangeLog addition:
2010-03-12 Ben Wing <ben@xemacs.org>
* automated/base64-tests.el (bt-base64-encode-string):
* automated/base64-tests.el (bt-base64-decode-string):
* automated/base64-tests.el (for):
* automated/byte-compiler-tests.el:
* automated/byte-compiler-tests.el (before-and-after-compile-equal):
* automated/case-tests.el (downcase-string):
* automated/case-tests.el (uni-mappings):
* automated/ccl-tests.el (ccl-test-normal-expr):
* automated/ccl-tests.el (ccl-test-map-instructions):
* automated/ccl-tests.el (ccl-test-suites):
* automated/database-tests.el (delete-database-files):
* automated/extent-tests.el (let):
* automated/extent-tests.el (insert):
* automated/extent-tests.el (props):
* automated/file-tests.el:
* automated/file-tests.el (for):
* automated/hash-table-tests.el (test):
* automated/hash-table-tests.el (for):
* automated/hash-table-tests.el (ht):
* automated/hash-table-tests.el (iterations):
* automated/hash-table-tests.el (h1):
* automated/hash-table-tests.el (equal):
* automated/hash-table-tests.el (=):
* automated/lisp-tests.el:
* automated/lisp-tests.el (eq):
* automated/lisp-tests.el (test-setq):
* automated/lisp-tests.el (my-vector):
* automated/lisp-tests.el (x):
* automated/lisp-tests.el (equal):
* automated/lisp-tests.el (y):
* automated/lisp-tests.el (featurep):
* automated/lisp-tests.el (=):
* automated/lisp-tests.el (six):
* automated/lisp-tests.el (three):
* automated/lisp-tests.el (one):
* automated/lisp-tests.el (two):
* automated/lisp-tests.el (five):
* automated/lisp-tests.el (test1):
* automated/lisp-tests.el (division-test):
* automated/lisp-tests.el (for):
* automated/lisp-tests.el (check-function-argcounts):
* automated/lisp-tests.el (z):
* automated/lisp-tests.el (eql):
* automated/lisp-tests.el (test-harness-risk-infloops):
* automated/lisp-tests.el (erase-buffer):
* automated/lisp-tests.el (sym):
* automated/lisp-tests.el (new-char):
* automated/lisp-tests.el (new-load-file-name):
* automated/lisp-tests.el (cl-floor):
* automated/lisp-tests.el (foo):
* automated/md5-tests.el (lambda):
* automated/md5-tests.el (large-string):
* automated/md5-tests.el (mapcar):
* automated/md5-tests.el (insert):
* automated/mule-tests.el:
* automated/mule-tests.el (test-chars):
* automated/mule-tests.el (existing-file-name):
* automated/mule-tests.el (featurep):
* automated/query-coding-tests.el (featurep):
* automated/regexp-tests.el:
* automated/regexp-tests.el (insert):
* automated/regexp-tests.el (Assert):
* automated/regexp-tests.el (=):
* automated/regexp-tests.el (featurep):
* automated/regexp-tests.el (text):
* automated/regexp-tests.el (text1):
* automated/regexp-tests.el ("aáa"):
* automated/regexp-tests.el (eql):
* automated/search-tests.el (insert):
* automated/search-tests.el (featurep):
* automated/search-tests.el (let):
* automated/search-tests.el (boundp):
* automated/symbol-tests.el:
* automated/symbol-tests.el (name):
* automated/symbol-tests.el (check-weak-list-unique):
* automated/symbol-tests.el (string):
* automated/symbol-tests.el (list):
* automated/symbol-tests.el (foo):
* automated/symbol-tests.el (eq):
* automated/symbol-tests.el (fresh-keyword-name):
* automated/symbol-tests.el (print-gensym):
* automated/symbol-tests.el (mysym):
* automated/syntax-tests.el (test-forward-word):
* automated/syntax-tests.el (test-backward-word):
* automated/syntax-tests.el (test-syntax-table):
* automated/syntax-tests.el (with-syntax-table):
* automated/syntax-tests.el (Skip-Test-Unless):
* automated/syntax-tests.el (with):
* automated/tag-tests.el (testfile):
* automated/weak-tests.el (w):
* automated/weak-tests.el (p):
* automated/weak-tests.el (a):
Undo change of e.g. (Assert (equalp ...)) to (Assert-equalp ...).
Get rid of `Assert-equalp' and friends, `Assert-test', and
`Assert-test-not'. Instead, make `Assert' smart enough to do the
equivalent functionality when an expression like (Assert (equalp ...))
is seen.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 12 Mar 2010 18:27:51 -0600 |
parents | efaa6cd845e5 |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
5113:b2dcf6a6d8ab | 5136:0f66906b6e37 |
---|---|
43 | 43 |
44 (with-temp-buffer | 44 (with-temp-buffer |
45 (insert "Test Buffer") | 45 (insert "Test Buffer") |
46 (let ((case-fold-search t)) | 46 (let ((case-fold-search t)) |
47 (goto-char (point-min)) | 47 (goto-char (point-min)) |
48 (Assert-eq (search-forward "test buffer" nil t) 12) | 48 (Assert (eq (search-forward "test buffer" nil t) 12)) |
49 (goto-char (point-min)) | 49 (goto-char (point-min)) |
50 (Assert-eq (search-forward "Test buffer" nil t) 12) | 50 (Assert (eq (search-forward "Test buffer" nil t) 12)) |
51 (goto-char (point-min)) | 51 (goto-char (point-min)) |
52 (Assert-eq (search-forward "Test Buffer" nil t) 12) | 52 (Assert (eq (search-forward "Test Buffer" nil t) 12)) |
53 | 53 |
54 (setq case-fold-search nil) | 54 (setq case-fold-search nil) |
55 (goto-char (point-min)) | 55 (goto-char (point-min)) |
56 (Assert (not (search-forward "test buffer" nil t))) | 56 (Assert (not (search-forward "test buffer" nil t))) |
57 (goto-char (point-min)) | 57 (goto-char (point-min)) |
58 (Assert (not (search-forward "Test buffer" nil t))) | 58 (Assert (not (search-forward "Test buffer" nil t))) |
59 (goto-char (point-min)) | 59 (goto-char (point-min)) |
60 (Assert-eq (search-forward "Test Buffer" nil t) 12))) | 60 (Assert (eq (search-forward "Test Buffer" nil t) 12)))) |
61 | 61 |
62 (with-temp-buffer | 62 (with-temp-buffer |
63 (insert "abcdefghijklmnäopqrstuÄvwxyz") | 63 (insert "abcdefghijklmnäopqrstuÄvwxyz") |
64 ;; case insensitive | 64 ;; case insensitive |
65 (Assert (not (search-forward "ö" nil t))) | 65 (Assert (not (search-forward "ö" nil t))) |
66 (goto-char (point-min)) | 66 (goto-char (point-min)) |
67 (Assert-eq 16 (search-forward "ä" nil t)) | 67 (Assert (eq 16 (search-forward "ä" nil t))) |
68 (Assert-eq 24 (search-forward "ä" nil t)) | 68 (Assert (eq 24 (search-forward "ä" nil t))) |
69 (goto-char (point-min)) | 69 (goto-char (point-min)) |
70 (Assert-eq 16 (search-forward "Ä" nil t)) | 70 (Assert (eq 16 (search-forward "Ä" nil t))) |
71 (Assert-eq 24 (search-forward "Ä" nil t)) | 71 (Assert (eq 24 (search-forward "Ä" nil t))) |
72 (goto-char (point-max)) | 72 (goto-char (point-max)) |
73 (Assert-eq 23 (search-backward "ä" nil t)) | 73 (Assert (eq 23 (search-backward "ä" nil t))) |
74 (Assert-eq 15 (search-backward "ä" nil t)) | 74 (Assert (eq 15 (search-backward "ä" nil t))) |
75 (goto-char (point-max)) | 75 (goto-char (point-max)) |
76 (Assert-eq 23 (search-backward "Ä" nil t)) | 76 (Assert (eq 23 (search-backward "Ä" nil t))) |
77 (Assert-eq 15 (search-backward "Ä" nil t)) | 77 (Assert (eq 15 (search-backward "Ä" nil t))) |
78 ;; case sensitive | 78 ;; case sensitive |
79 (setq case-fold-search nil) | 79 (setq case-fold-search nil) |
80 (goto-char (point-min)) | 80 (goto-char (point-min)) |
81 (Assert (not (search-forward "ö" nil t))) | 81 (Assert (not (search-forward "ö" nil t))) |
82 (goto-char (point-min)) | 82 (goto-char (point-min)) |
83 (Assert-eq 16 (search-forward "ä" nil t)) | 83 (Assert (eq 16 (search-forward "ä" nil t))) |
84 (Assert (not (search-forward "ä" nil t))) | 84 (Assert (not (search-forward "ä" nil t))) |
85 (goto-char (point-min)) | 85 (goto-char (point-min)) |
86 (Assert-eq 24 (search-forward "Ä" nil t)) | 86 (Assert (eq 24 (search-forward "Ä" nil t))) |
87 (goto-char 16) | 87 (goto-char 16) |
88 (Assert-eq 24 (search-forward "Ä" nil t)) | 88 (Assert (eq 24 (search-forward "Ä" nil t))) |
89 (goto-char (point-max)) | 89 (goto-char (point-max)) |
90 (Assert-eq 15 (search-backward "ä" nil t)) | 90 (Assert (eq 15 (search-backward "ä" nil t))) |
91 (goto-char 15) | 91 (goto-char 15) |
92 (Assert (not (search-backward "ä" nil t))) | 92 (Assert (not (search-backward "ä" nil t))) |
93 (goto-char (point-max)) | 93 (goto-char (point-max)) |
94 (Assert-eq 23 (search-backward "Ä" nil t)) | 94 (Assert (eq 23 (search-backward "Ä" nil t))) |
95 (Assert (not (search-backward "Ä" nil t)))) | 95 (Assert (not (search-backward "Ä" nil t)))) |
96 | 96 |
97 (with-temp-buffer | 97 (with-temp-buffer |
98 (insert "aaaaäÄäÄäÄäÄäÄbbbb") | 98 (insert "aaaaäÄäÄäÄäÄäÄbbbb") |
99 (goto-char (point-min)) | 99 (goto-char (point-min)) |
100 (Assert-eq 15 (search-forward "ää" nil t 5)) | 100 (Assert (eq 15 (search-forward "ää" nil t 5))) |
101 (goto-char (point-min)) | 101 (goto-char (point-min)) |
102 (Assert (not (search-forward "ää" nil t 6))) | 102 (Assert (not (search-forward "ää" nil t 6))) |
103 (goto-char (point-max)) | 103 (goto-char (point-max)) |
104 (Assert-eq 5 (search-backward "ää" nil t 5)) | 104 (Assert (eq 5 (search-backward "ää" nil t 5))) |
105 (goto-char (point-max)) | 105 (goto-char (point-max)) |
106 (Assert (not (search-backward "ää" nil t 6)))) | 106 (Assert (not (search-backward "ää" nil t 6)))) |
107 | 107 |
108 (when (featurep 'mule) | 108 (when (featurep 'mule) |
109 (let* ((hiragana-a (make-char 'japanese-jisx0208 36 34)) | 109 (let* ((hiragana-a (make-char 'japanese-jisx0208 36 34)) |
118 (insert hiragana-a "abcdefg" a-diaeresis) | 118 (insert hiragana-a "abcdefg" a-diaeresis) |
119 ;; forward | 119 ;; forward |
120 (goto-char (point-min)) | 120 (goto-char (point-min)) |
121 (Assert (not (search-forward "ö" nil t))) | 121 (Assert (not (search-forward "ö" nil t))) |
122 (goto-char (point-min)) | 122 (goto-char (point-min)) |
123 (Assert-eq 2 (search-forward str-hiragana-a nil t)) | 123 (Assert (eq 2 (search-forward str-hiragana-a nil t))) |
124 (goto-char (point-min)) | 124 (goto-char (point-min)) |
125 (Assert-eq 2 (search-forward str-a-diaeresis nil t)) | 125 (Assert (eq 2 (search-forward str-a-diaeresis nil t))) |
126 (goto-char (1+ (point-min))) | 126 (goto-char (1+ (point-min))) |
127 (Assert-eq (point-max) | 127 (Assert (eq (point-max) |
128 (search-forward str-hiragana-a nil t)) | 128 (search-forward str-hiragana-a nil t))) |
129 (goto-char (1+ (point-min))) | 129 (goto-char (1+ (point-min))) |
130 (Assert-eq (point-max) | 130 (Assert (eq (point-max) |
131 (search-forward str-a-diaeresis nil t)) | 131 (search-forward str-a-diaeresis nil t))) |
132 ;; backward | 132 ;; backward |
133 (goto-char (point-max)) | 133 (goto-char (point-max)) |
134 (Assert (not (search-backward "ö" nil t))) | 134 (Assert (not (search-backward "ö" nil t))) |
135 (goto-char (point-max)) | 135 (goto-char (point-max)) |
136 (Assert-eq (1- (point-max)) (search-backward str-hiragana-a nil t)) | 136 (Assert (eq (1- (point-max)) (search-backward str-hiragana-a nil t))) |
137 (goto-char (point-max)) | 137 (goto-char (point-max)) |
138 (Assert-eq (1- (point-max)) (search-backward str-a-diaeresis nil t)) | 138 (Assert (eq (1- (point-max)) (search-backward str-a-diaeresis nil t))) |
139 (goto-char (1- (point-max))) | 139 (goto-char (1- (point-max))) |
140 (Assert-eq 1 (search-backward str-hiragana-a nil t)) | 140 (Assert (eq 1 (search-backward str-hiragana-a nil t))) |
141 (goto-char (1- (point-max))) | 141 (goto-char (1- (point-max))) |
142 (Assert-eq 1 (search-backward str-a-diaeresis nil t)) | 142 (Assert (eq 1 (search-backward str-a-diaeresis nil t))) |
143 (replace-match "a") | 143 (replace-match "a") |
144 (Assert (looking-at (format "abcdefg%c" a-diaeresis)))) | 144 (Assert (looking-at (format "abcdefg%c" a-diaeresis)))) |
145 (with-temp-buffer | 145 (with-temp-buffer |
146 (set-case-table case-table) | 146 (set-case-table case-table) |
147 (insert string) | 147 (insert string) |
148 (insert string) | 148 (insert string) |
149 (insert string) | 149 (insert string) |
150 (insert string) | 150 (insert string) |
151 (insert string) | 151 (insert string) |
152 (goto-char (point-min)) | 152 (goto-char (point-min)) |
153 (Assert-eq 11 (search-forward string nil t 5)) | 153 (Assert (eq 11 (search-forward string nil t 5))) |
154 (goto-char (point-min)) | 154 (goto-char (point-min)) |
155 (Assert (not (search-forward string nil t 6))) | 155 (Assert (not (search-forward string nil t 6))) |
156 (goto-char (point-max)) | 156 (goto-char (point-max)) |
157 (Assert-eq 1 (search-backward string nil t 5)) | 157 (Assert (eq 1 (search-backward string nil t 5))) |
158 (goto-char (point-max)) | 158 (goto-char (point-max)) |
159 (Assert (not (search-backward string nil t 6)))))) | 159 (Assert (not (search-backward string nil t 6)))))) |
160 | 160 |
161 ;; Bug reported in http://mid.gmane.org/y9lk5lu5orq.fsf@deinprogramm.de from | 161 ;; Bug reported in http://mid.gmane.org/y9lk5lu5orq.fsf@deinprogramm.de from |
162 ;; Michael Sperber. Fixed 2008-01-29. | 162 ;; Michael Sperber. Fixed 2008-01-29. |
175 ;; Boyer-Moore. | 175 ;; Boyer-Moore. |
176 ;; | 176 ;; |
177 ;; But searches for ASCII strings in buffers with nothing above ?\xFF | 177 ;; But searches for ASCII strings in buffers with nothing above ?\xFF |
178 ;; use Boyer Moore with the current implementation, which is the | 178 ;; use Boyer Moore with the current implementation, which is the |
179 ;; important thing for the Gnus use case. | 179 ;; important thing for the Gnus use case. |
180 (Assert= (1+ (length target)) (search-forward target nil t)))) | 180 (Assert (= (1+ (length target)) (search-forward target nil t))))) |
181 | 181 |
182 (Skip-Test-Unless | 182 (Skip-Test-Unless |
183 (boundp 'debug-searches) ; normal when we have DEBUG_XEMACS | 183 (boundp 'debug-searches) ; normal when we have DEBUG_XEMACS |
184 "not a DEBUG_XEMACS build" | 184 "not a DEBUG_XEMACS build" |
185 "checks that the algorithm chosen by #'search-forward is relatively sane" | 185 "checks that the algorithm chosen by #'search-forward is relatively sane" |
191 (Assert (search-forward "Fleiss")) | 191 (Assert (search-forward "Fleiss")) |
192 (delete-region (point-min) (point-max)) | 192 (delete-region (point-min) (point-max)) |
193 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n") | 193 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n") |
194 (goto-char (point-min)) | 194 (goto-char (point-min)) |
195 (Assert (search-forward "Flei\xdf")) | 195 (Assert (search-forward "Flei\xdf")) |
196 (Assert-eq 'boyer-moore search-algorithm-used) | 196 (Assert (eq 'boyer-moore search-algorithm-used)) |
197 (delete-region (point-min) (point-max)) | 197 (delete-region (point-min) (point-max)) |
198 (when (featurep 'mule) | 198 (when (featurep 'mule) |
199 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n") | 199 (insert "\n\nDer ber\xfchmte deutsche Flei\xdf\n\n") |
200 (goto-char (point-min)) | 200 (goto-char (point-min)) |
201 (Assert | 201 (Assert |
202 (search-forward (format "Fle%c\xdf" | 202 (search-forward (format "Fle%c\xdf" |
203 (make-char 'latin-iso8859-9 #xfd)))) | 203 (make-char 'latin-iso8859-9 #xfd)))) |
204 (Assert-eq 'boyer-moore search-algorithm-used) | 204 (Assert (eq 'boyer-moore search-algorithm-used)) |
205 (insert (make-char 'latin-iso8859-9 #xfd)) | 205 (insert (make-char 'latin-iso8859-9 #xfd)) |
206 (goto-char (point-min)) | 206 (goto-char (point-min)) |
207 (Assert (search-forward "Flei\xdf")) | 207 (Assert (search-forward "Flei\xdf")) |
208 (Assert-eq 'simple-search search-algorithm-used) | 208 (Assert (eq 'simple-search search-algorithm-used)) |
209 (goto-char (point-min)) | 209 (goto-char (point-min)) |
210 (Assert (search-forward (format "Fle%c\xdf" | 210 (Assert (search-forward (format "Fle%c\xdf" |
211 (make-char 'latin-iso8859-9 #xfd)))) | 211 (make-char 'latin-iso8859-9 #xfd)))) |
212 (Assert-eq 'simple-search search-algorithm-used) | 212 (Assert (eq 'simple-search search-algorithm-used)) |
213 (setq newcase (copy-case-table (standard-case-table))) | 213 (setq newcase (copy-case-table (standard-case-table))) |
214 (put-case-table-pair (make-char 'ethiopic #x23 #x23) | 214 (put-case-table-pair (make-char 'ethiopic #x23 #x23) |
215 (make-char 'ethiopic #x23 #x25) | 215 (make-char 'ethiopic #x23 #x25) |
216 newcase) | 216 newcase) |
217 (with-case-table | 217 (with-case-table |
223 (delete-region (point-min) (point-max)) | 223 (delete-region (point-min) (point-max)) |
224 (insert ?0) | 224 (insert ?0) |
225 (insert (make-char 'ethiopic #x23 #x23)) | 225 (insert (make-char 'ethiopic #x23 #x23)) |
226 (insert ?1) | 226 (insert ?1) |
227 (goto-char (point-min)) | 227 (goto-char (point-min)) |
228 (Assert-eql (search-forward | 228 (Assert (eql (search-forward |
229 (string (make-char 'ethiopic #x23 #x25)) | 229 (string (make-char 'ethiopic #x23 #x25)) |
230 nil t) | 230 nil t) |
231 3) | 231 3)) |
232 (Assert-eq 'simple-search search-algorithm-used) | 232 (Assert (eq 'simple-search search-algorithm-used)) |
233 (goto-char (point-min)) | 233 (goto-char (point-min)) |
234 (Assert-eql (search-forward | 234 (Assert (eql (search-forward |
235 (string (make-char 'ethiopic #x23 #x27)) | 235 (string (make-char 'ethiopic #x23 #x27)) |
236 nil t) | 236 nil t) |
237 nil) | 237 nil)) |
238 (Assert-eq 'boyer-moore search-algorithm-used)))))) | 238 (Assert (eq 'boyer-moore search-algorithm-used))))))) |
239 | 239 |
240 ;; XEmacs bug of long standing. | 240 ;; XEmacs bug of long standing. |
241 | 241 |
242 (with-temp-buffer | 242 (with-temp-buffer |
243 (insert "foo\201bar") | 243 (insert "foo\201bar") |
244 (goto-char (point-min)) | 244 (goto-char (point-min)) |
245 (Assert-eq (search-forward "\201" nil t) 5)) | 245 (Assert (eq (search-forward "\201" nil t) 5))) |