comparison tests/automated/query-coding-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 189fb67ca31a
children 3889ef128488 308d34e9f07d
comparison
equal deleted inserted replaced
5113:b2dcf6a6d8ab 5136:0f66906b6e37
68 unix-coding-system))) 68 unix-coding-system)))
69 (coding-system-list nil)) 69 (coding-system-list nil))
70 :test #'eq)) 70 :test #'eq))
71 (multiple-value-bind (query-coding-succeeded query-coding-table) 71 (multiple-value-bind (query-coding-succeeded query-coding-table)
72 (query-coding-region (point-min) (point-max) coding-system) 72 (query-coding-region (point-min) (point-max) coding-system)
73 (Assert-eq t query-coding-succeeded 73 (Assert (eq t query-coding-succeeded)
74 (format "checking query-coding-region ASCII-transparency, %s" 74 (format "checking query-coding-region ASCII-transparency, %s"
75 coding-system)) 75 coding-system))
76 (Assert (null query-coding-table) 76 (Assert (null query-coding-table)
77 (format "checking query-coding-region ASCII-transparency, %s" 77 (format "checking query-coding-region ASCII-transparency, %s"
78 coding-system))) 78 coding-system)))
79 (multiple-value-bind (query-coding-succeeded query-coding-table) 79 (multiple-value-bind (query-coding-succeeded query-coding-table)
80 (query-coding-string ascii-chars-string coding-system) 80 (query-coding-string ascii-chars-string coding-system)
81 (Assert-eq t query-coding-succeeded 81 (Assert (eq t query-coding-succeeded)
82 (format "checking query-coding-string ASCII-transparency, %s" 82 (format "checking query-coding-string ASCII-transparency, %s"
83 coding-system)) 83 coding-system))
84 (Assert (null query-coding-table) 84 (Assert (null query-coding-table)
85 (format "checking query-coding-string ASCII-transparency, %s" 85 (format "checking query-coding-string ASCII-transparency, %s"
86 coding-system)))) 86 coding-system))))
87 (delete-region (point-min) (point-max)) 87 (delete-region (point-min) (point-max))
88 ;; Check for success from the two Latin-1 coding systems 88 ;; Check for success from the two Latin-1 coding systems
89 (insert latin-1-chars-string) 89 (insert latin-1-chars-string)
90 (multiple-value-bind (query-coding-succeeded query-coding-table) 90 (multiple-value-bind (query-coding-succeeded query-coding-table)
91 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) 91 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix)
92 (Assert-eq t query-coding-succeeded 92 (Assert (eq t query-coding-succeeded)
93 "checking query-coding-region iso-8859-1-transparency") 93 "checking query-coding-region iso-8859-1-transparency")
94 (Assert (null query-coding-table) 94 (Assert (null query-coding-table)
95 "checking query-coding-region iso-8859-1-transparency")) 95 "checking query-coding-region iso-8859-1-transparency"))
96 (multiple-value-bind (query-coding-succeeded query-coding-table) 96 (multiple-value-bind (query-coding-succeeded query-coding-table)
97 (query-coding-string (buffer-string) 'iso-8859-1-unix) 97 (query-coding-string (buffer-string) 'iso-8859-1-unix)
98 (Assert-eq t query-coding-succeeded 98 (Assert (eq t query-coding-succeeded)
99 "checking query-coding-string iso-8859-1-transparency") 99 "checking query-coding-string iso-8859-1-transparency")
100 (Assert (null query-coding-table) 100 (Assert (null query-coding-table)
101 "checking query-coding-string iso-8859-1-transparency")) 101 "checking query-coding-string iso-8859-1-transparency"))
102 (multiple-value-bind (query-coding-succeeded query-coding-table) 102 (multiple-value-bind (query-coding-succeeded query-coding-table)
103 (query-coding-string (buffer-string) 'iso-latin-1-with-esc-unix) 103 (query-coding-string (buffer-string) 'iso-latin-1-with-esc-unix)
104 (Assert-eq t query-coding-succeeded 104 (Assert
105 (eq t query-coding-succeeded)
105 "checking query-coding-region iso-latin-1-with-esc-transparency") 106 "checking query-coding-region iso-latin-1-with-esc-transparency")
106 (Assert 107 (Assert
107 (null query-coding-table) 108 (null query-coding-table)
108 "checking query-coding-region iso-latin-1-with-esc-transparency")) 109 "checking query-coding-region iso-latin-1-with-esc-transparency"))
109 ;; Make it fail, check that it fails correctly 110 ;; Make it fail, check that it fails correctly
111 (multiple-value-bind (query-coding-succeeded query-coding-table) 112 (multiple-value-bind (query-coding-succeeded query-coding-table)
112 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix) 113 (query-coding-region (point-min) (point-max) 'iso-8859-1-unix)
113 (Assert 114 (Assert
114 (null query-coding-succeeded) 115 (null query-coding-succeeded)
115 "checking that query-coding-region fails, U+20AC, iso-8859-1") 116 "checking that query-coding-region fails, U+20AC, iso-8859-1")
116 (Assert-equal query-coding-table 117 (Assert
118 (equal query-coding-table
117 #s(range-table type start-closed-end-open data 119 #s(range-table type start-closed-end-open data
118 ((257 258) unencodable)) 120 ((257 258) unencodable)))
119 "checking query-coding-region fails correctly, U+20AC, iso-8859-1")) 121 "checking query-coding-region fails correctly, U+20AC, iso-8859-1"))
120 (multiple-value-bind (query-coding-succeeded query-coding-table) 122 (multiple-value-bind (query-coding-succeeded query-coding-table)
121 (query-coding-region (point-min) (point-max) 123 (query-coding-region (point-min) (point-max)
122 'iso-latin-1-with-esc-unix) 124 'iso-latin-1-with-esc-unix)
123 ;; Stupidly, this succeeds. The behaviour is compatible with 125 ;; Stupidly, this succeeds. The behaviour is compatible with
157 (multiple-value-bind (query-coding-succeeded query-coding-table) 159 (multiple-value-bind (query-coding-succeeded query-coding-table)
158 (query-coding-region (point-min) (point-max) 'windows-1252-unix) 160 (query-coding-region (point-min) (point-max) 'windows-1252-unix)
159 (Assert 161 (Assert
160 (null query-coding-succeeded) 162 (null query-coding-succeeded)
161 "check query-coding-region fails, windows-1252, invalid-sequences") 163 "check query-coding-region fails, windows-1252, invalid-sequences")
162 (Assert-equal query-coding-table 164 (Assert
165 (equal query-coding-table
163 #s(range-table type start-closed-end-open 166 #s(range-table type start-closed-end-open
164 data ((130 131) invalid-sequence 167 data ((130 131) invalid-sequence
165 (142 143) invalid-sequence 168 (142 143) invalid-sequence
166 (144 146) invalid-sequence 169 (144 146) invalid-sequence
167 (158 159) invalid-sequence)) 170 (158 159) invalid-sequence)))
168 "check query-coding-region fails, windows-1252, invalid-sequences")) 171 "check query-coding-region fails, windows-1252, invalid-sequences"))
169 (multiple-value-bind (query-coding-succeeded query-coding-table) 172 (multiple-value-bind (query-coding-succeeded query-coding-table)
170 (query-coding-region (point-min) (point-max) 'windows-1252-unix 173 (query-coding-region (point-min) (point-max) 'windows-1252-unix
171 (current-buffer) t) 174 (current-buffer) t)
172 (Assert-eq t query-coding-succeeded 175 (Assert
176 (eq t query-coding-succeeded)
173 "checking that query-coding-region succeeds, U+20AC, windows-1252") 177 "checking that query-coding-region succeeds, U+20AC, windows-1252")
174 (Assert 178 (Assert
175 (null query-coding-table) 179 (null query-coding-table)
176 "checking that query-coding-region succeeds, U+20AC, windows-1252")) 180 "checking that query-coding-region succeeds, U+20AC, windows-1252"))
177 (insert ?\x80) 181 (insert ?\x80)
179 (query-coding-region (point-min) (point-max) 'windows-1252-unix 183 (query-coding-region (point-min) (point-max) 'windows-1252-unix
180 (current-buffer) t) 184 (current-buffer) t)
181 (Assert 185 (Assert
182 (null query-coding-succeeded) 186 (null query-coding-succeeded)
183 "checking that query-coding-region fails, U+0080, windows-1252") 187 "checking that query-coding-region fails, U+0080, windows-1252")
184 (Assert-equal query-coding-table 188 (Assert
189 (equal query-coding-table
185 #s(range-table type start-closed-end-open data 190 #s(range-table type start-closed-end-open data
186 ((257 258) unencodable)) 191 ((257 258) unencodable)))
187 "checking that query-coding-region fails, U+0080, windows-1252")) 192 "checking that query-coding-region fails, U+0080, windows-1252"))
188 (multiple-value-bind (query-coding-succeeded query-coding-table) 193 (multiple-value-bind (query-coding-succeeded query-coding-table)
189 (query-coding-region (point-min) (point-max) 'windows-1252-unix) 194 (query-coding-region (point-min) (point-max) 'windows-1252-unix)
190 (Assert 195 (Assert
191 (null query-coding-succeeded) 196 (null query-coding-succeeded)
192 "check query-coding-region fails, U+0080, invalid-sequence, cp1252") 197 "check query-coding-region fails, U+0080, invalid-sequence, cp1252")
193 (Assert-equal query-coding-table 198 (Assert
199 (equal query-coding-table
194 #s(range-table type start-closed-end-open 200 #s(range-table type start-closed-end-open
195 data ((130 131) invalid-sequence 201 data ((130 131) invalid-sequence
196 (142 143) invalid-sequence 202 (142 143) invalid-sequence
197 (144 146) invalid-sequence 203 (144 146) invalid-sequence
198 (158 159) invalid-sequence 204 (158 159) invalid-sequence
199 (257 258) unencodable)) 205 (257 258) unencodable)))
200 "check query-coding-region fails, U+0080, invalid-sequence, cp1252")) 206 "check query-coding-region fails, U+0080, invalid-sequence, cp1252"))
201 ;; Try a similar approach with koi8-o, the koi8 variant with 207 ;; Try a similar approach with koi8-o, the koi8 variant with
202 ;; support for Old Church Slavonic. 208 ;; support for Old Church Slavonic.
203 (delete-region (point-min) (point-max)) 209 (delete-region (point-min) (point-max))
204 (insert latin-1-chars-string) 210 (insert latin-1-chars-string)
211 (Assert 217 (Assert
212 (null query-coding-table) 218 (null query-coding-table)
213 "checking that query-coding-region succeeds, koi8-o-unix")) 219 "checking that query-coding-region succeeds, koi8-o-unix"))
214 (multiple-value-bind (query-coding-succeeded query-coding-table) 220 (multiple-value-bind (query-coding-succeeded query-coding-table)
215 (query-coding-region (point-min) (point-max) 'escape-quoted) 221 (query-coding-region (point-min) (point-max) 'escape-quoted)
216 (Assert-eq t query-coding-succeeded 222 (Assert (eq t query-coding-succeeded)
217 "checking that query-coding-region succeeds, escape-quoted") 223 "checking that query-coding-region succeeds, escape-quoted")
218 (Assert (null query-coding-table) 224 (Assert (null query-coding-table)
219 "checking that query-coding-region succeeds, escape-quoted")) 225 "checking that query-coding-region succeeds, escape-quoted"))
220 (multiple-value-bind (query-coding-succeeded query-coding-table) 226 (multiple-value-bind (query-coding-succeeded query-coding-table)
221 (query-coding-region (point-min) (point-max) 'windows-1252-unix) 227 (query-coding-region (point-min) (point-max) 'windows-1252-unix)
275 utf-16-little-endian-bom)) 281 utf-16-little-endian-bom))
276 (multiple-value-bind (query-coding-succeeded query-coding-table) 282 (multiple-value-bind (query-coding-succeeded query-coding-table)
277 (query-coding-region (point-min) (point-max) coding-system) 283 (query-coding-region (point-min) (point-max) coding-system)
278 (Assert (null query-coding-succeeded) 284 (Assert (null query-coding-succeeded)
279 "checking unicode coding systems fail with unmapped chars") 285 "checking unicode coding systems fail with unmapped chars")
280 (Assert-equal query-coding-table 286 (Assert (equal query-coding-table
281 #s(range-table type start-closed-end-open data 287 #s(range-table type start-closed-end-open data
282 ((173 174) unencodable 288 ((173 174) unencodable
283 (209 210) unencodable 289 (209 210) unencodable
284 (254 255) unencodable)) 290 (254 255) unencodable)))
285 "checking unicode coding systems fail with unmapped chars")) 291 "checking unicode coding systems fail with unmapped chars"))
286 (multiple-value-bind (query-coding-succeeded query-coding-table) 292 (multiple-value-bind (query-coding-succeeded query-coding-table)
287 (query-coding-region (point-min) 173 coding-system) 293 (query-coding-region (point-min) 173 coding-system)
288 (Assert-eq t query-coding-succeeded 294 (Assert (eq t query-coding-succeeded)
289 "checking unicode coding systems succeed sans unmapped chars") 295 "checking unicode coding systems succeed sans unmapped chars")
290 (Assert 296 (Assert
291 (null query-coding-table) 297 (null query-coding-table)
292 "checking unicode coding systems succeed sans unmapped chars")) 298 "checking unicode coding systems succeed sans unmapped chars"))
293 (multiple-value-bind (query-coding-succeeded query-coding-table) 299 (multiple-value-bind (query-coding-succeeded query-coding-table)
298 (Assert 304 (Assert
299 (null query-coding-table) 305 (null query-coding-table)
300 "checking unicode coding systems succeed sans unmapped chars again")) 306 "checking unicode coding systems succeed sans unmapped chars again"))
301 (multiple-value-bind (query-coding-succeeded query-coding-table) 307 (multiple-value-bind (query-coding-succeeded query-coding-table)
302 (query-coding-region 210 254 coding-system) 308 (query-coding-region 210 254 coding-system)
303 (Assert-eq t query-coding-succeeded) 309 (Assert (eq t query-coding-succeeded))
304 (Assert (null query-coding-table))) 310 (Assert (null query-coding-table)))
305 ;; Check that it errors correctly. 311 ;; Check that it errors correctly.
306 (setq text-conversion-error-signalled nil) 312 (setq text-conversion-error-signalled nil)
307 (condition-case nil 313 (condition-case nil
308 (query-coding-region (point-min) (point-max) coding-system 314 (query-coding-region (point-min) (point-max) coding-system
334 (query-coding-region (point-min) (point-max) coding-system) 340 (query-coding-region (point-min) (point-max) coding-system)
335 (Assert (null query-coding-succeeded) 341 (Assert (null query-coding-succeeded)
336 (format 342 (format
337 "checking %s fails with unmapped chars and invalid seqs" 343 "checking %s fails with unmapped chars and invalid seqs"
338 coding-system)) 344 coding-system))
339 (Assert-equal query-coding-table 345 (Assert (equal query-coding-table
340 #s(range-table type start-closed-end-open 346 #s(range-table type start-closed-end-open
341 data ((1 5) unencodable 347 data ((1 5) unencodable
342 (5 9) invalid-sequence 348 (5 9) invalid-sequence
343 (9 13) unencodable)) 349 (9 13) unencodable)))
344 (format 350 (format
345 "checking %s fails with unmapped chars and invalid seqs" 351 "checking %s fails with unmapped chars and invalid seqs"
346 coding-system))) 352 coding-system)))
347 (multiple-value-bind (query-coding-succeeded query-coding-table) 353 (multiple-value-bind (query-coding-succeeded query-coding-table)
348 (query-coding-region (point-min) (point-max) coding-system 354 (query-coding-region (point-min) (point-max) coding-system
388 (equal '(257) (unencodable-char-position (point-min) (point-max) 394 (equal '(257) (unencodable-char-position (point-min) (point-max)
389 'iso-8859-1 0)) 395 'iso-8859-1 0))
390 "check #'unencodable-char-position has some borked GNU semantics") 396 "check #'unencodable-char-position has some borked GNU semantics")
391 (dotimes (i 6) (insert (decode-char 'ucs #x20ac))) 397 (dotimes (i 6) (insert (decode-char 'ucs #x20ac)))
392 ;; Check if it stops at one: 398 ;; Check if it stops at one:
393 (Assert-equal '(257) (unencodable-char-position (point-min) (point-max) 399 (Assert (equal '(257) (unencodable-char-position (point-min) (point-max)
394 'iso-8859-1 1) 400 'iso-8859-1 1))
395 "check #'unencodable-char-position stops at 1 when asked to") 401 "check #'unencodable-char-position stops at 1 when asked to")
396 ;; Check if it stops at four: 402 ;; Check if it stops at four:
397 (Assert-equal '(260 259 258 257) 403 (Assert (equal '(260 259 258 257)
398 (unencodable-char-position (point-min) (point-max) 404 (unencodable-char-position (point-min) (point-max)
399 'iso-8859-1 4) 405 'iso-8859-1 4))
400 "check #'unencodable-char-position stops at 4 when asked to") 406 "check #'unencodable-char-position stops at 4 when asked to")
401 ;; Check whether it stops at seven: 407 ;; Check whether it stops at seven:
402 (Assert-equal '(263 262 261 260 259 258 257) 408 (Assert (equal '(263 262 261 260 259 258 257)
403 (unencodable-char-position (point-min) (point-max) 409 (unencodable-char-position (point-min) (point-max)
404 'iso-8859-1 7) 410 'iso-8859-1 7))
405 "check #'unencodable-char-position stops at 7 when asked to") 411 "check #'unencodable-char-position stops at 7 when asked to")
406 ;; Check that it still stops at seven: 412 ;; Check that it still stops at seven:
407 (Assert-equal '(263 262 261 260 259 258 257) 413 (Assert (equal '(263 262 261 260 259 258 257)
408 (unencodable-char-position (point-min) (point-max) 414 (unencodable-char-position (point-min) (point-max)
409 'iso-8859-1 2000) 415 'iso-8859-1 2000))
410 "check #'unencodable-char-position stops at 7 if 2000 asked for") 416 "check #'unencodable-char-position stops at 7 if 2000 asked for")
411 ;; Now, #'check-coding-systems-region. 417 ;; Now, #'check-coding-systems-region.
412 ;; UTF-8 should certainly be able to encode these characters: 418 ;; UTF-8 should certainly be able to encode these characters:
413 (Assert (null (check-coding-systems-region (point-min) (point-max) 419 (Assert (null (check-coding-systems-region (point-min) (point-max)
414 '(utf-8))) 420 '(utf-8)))