Mercurial > hg > xemacs-beta
comparison tests/automated/lisp-tests.el @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | aabb7f5b1c81 |
children | 697ef44129c6 |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
20 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free | 21 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
23 ;; 02111-1307, USA. | 23 ;; 02111-1307, USA. |
24 | 24 |
25 ;;; Synched up with: not in FSF Emacs. | 25 ;;; Synched up with: Not in FSF. |
26 | 26 |
27 ;;; Commentary: | 27 ;;; Commentary: |
28 | 28 |
29 ;;; Test basic Lisp engine functionality | 29 ;;; Test basic Lisp engine functionality |
30 ;;; See test-harness.el for instructions on how to run these tests. | 30 ;;; See test-harness.el for instructions on how to run these tests. |
117 ;;----------------------------------------------------- | 117 ;;----------------------------------------------------- |
118 (defun make-list-012 () (list 0 1 2)) | 118 (defun make-list-012 () (list 0 1 2)) |
119 | 119 |
120 (Check-Error wrong-type-argument (nconc 'foo nil)) | 120 (Check-Error wrong-type-argument (nconc 'foo nil)) |
121 | 121 |
122 (dolist (length `(1 2 3 4 1000 2000)) | 122 (dolist (length '(1 2 3 4 1000 2000)) |
123 (Check-Error circular-list (nconc (make-circular-list length) 'foo)) | 123 (Check-Error circular-list (nconc (make-circular-list length) 'foo)) |
124 (Check-Error circular-list (nconc '(1 . 2) (make-circular-list length) 'foo)) | 124 (Check-Error circular-list (nconc '(1 . 2) (make-circular-list length) 'foo)) |
125 (Check-Error circular-list (nconc '(1 . 2) '(3 . 4) (make-circular-list length) 'foo))) | 125 (Check-Error circular-list (nconc '(1 . 2) '(3 . 4) (make-circular-list length) 'foo))) |
126 | 126 |
127 (Assert (eq (nconc) nil)) | 127 (Assert (eq (nconc) nil)) |
156 (Assert (eq (last x 1) (cdddr x))) | 156 (Assert (eq (last x 1) (cdddr x))) |
157 (Assert (eq (last x 2) (cddr x))) | 157 (Assert (eq (last x 2) (cddr x))) |
158 (Assert (eq (last x 3) (cdr x))) | 158 (Assert (eq (last x 3) (cdr x))) |
159 (Assert (eq (last x 4) x)) | 159 (Assert (eq (last x 4) x)) |
160 (Assert (eq (last x 9) x)) | 160 (Assert (eq (last x 9) x)) |
161 (Assert (eq (last `(1 . 2) 0) 2)) | 161 (Assert (eq (last '(1 . 2) 0) 2)) |
162 ) | 162 ) |
163 | 163 |
164 ;;----------------------------------------------------- | 164 ;;----------------------------------------------------- |
165 ;; Test `butlast' and `nbutlast' | 165 ;; Test `butlast' and `nbutlast' |
166 ;;----------------------------------------------------- | 166 ;;----------------------------------------------------- |
211 (Check-Error wrong-number-of-arguments (copy-list)) | 211 (Check-Error wrong-number-of-arguments (copy-list)) |
212 (Check-Error wrong-number-of-arguments (copy-list '(1 2) 1)) | 212 (Check-Error wrong-number-of-arguments (copy-list '(1 2) 1)) |
213 (Check-Error circular-list (copy-list (make-circular-list 1))) | 213 (Check-Error circular-list (copy-list (make-circular-list 1))) |
214 (Check-Error circular-list (copy-list (make-circular-list 2000))) | 214 (Check-Error circular-list (copy-list (make-circular-list 2000))) |
215 (Assert (eq '() (copy-list '()))) | 215 (Assert (eq '() (copy-list '()))) |
216 (dolist (x `((1) (1 2) (1 2 3) (1 2 . 3))) | 216 (dolist (x '((1) (1 2) (1 2 3) (1 2 . 3))) |
217 (let ((y (copy-list x))) | 217 (let ((y (copy-list x))) |
218 (Assert (and (equal x y) (not (eq x y)))))) | 218 (Assert (and (equal x y) (not (eq x y)))))) |
219 | 219 |
220 ;;----------------------------------------------------- | 220 ;;----------------------------------------------------- |
221 ;; Arithmetic operations | 221 ;; Arithmetic operations |
227 (Assert (= (+ 1.0 3.0 0.0) 4.0)) | 227 (Assert (= (+ 1.0 3.0 0.0) 4.0)) |
228 (Assert (= (+ 1 1.0) 2.0)) | 228 (Assert (= (+ 1 1.0) 2.0)) |
229 (Assert (= (+ 1.0 1) 2.0)) | 229 (Assert (= (+ 1.0 1) 2.0)) |
230 (Assert (= (+ 1.0 1 1) 3.0)) | 230 (Assert (= (+ 1.0 1 1) 3.0)) |
231 (Assert (= (+ 1 1 1.0) 3.0)) | 231 (Assert (= (+ 1 1 1.0) 3.0)) |
232 (Assert (eq (1+ most-positive-fixnum) most-negative-fixnum)) | |
233 (Assert (eq (+ most-positive-fixnum 1) most-negative-fixnum)) | |
232 | 234 |
233 ;; Test `-' | 235 ;; Test `-' |
234 (Check-Error wrong-number-of-arguments (-)) | 236 (Check-Error wrong-number-of-arguments (-)) |
235 (Assert (eq (- 0) 0)) | 237 (Assert (eq (- 0) 0)) |
236 (Assert (eq (- 1) -1)) | 238 (Assert (eq (- 1) -1)) |
240 (Assert (= (+ one) one)) | 242 (Assert (= (+ one) one)) |
241 (Assert (= (- one) -1)) | 243 (Assert (= (- one) -1)) |
242 (Assert (= (- one one) 0)) | 244 (Assert (= (- one one) 0)) |
243 (Assert (= (- one one one) -1)) | 245 (Assert (= (- one one one) -1)) |
244 (Assert (= (+ one 1) 2)) | 246 (Assert (= (+ one 1) 2)) |
245 (dolist (zero `(0 0.0 ?\0)) | 247 (dolist (zero '(0 0.0 ?\0)) |
246 (Assert (= (+ 1 zero) 1)) | 248 (Assert (= (+ 1 zero) 1)) |
247 (Assert (= (+ zero 1) 1)) | 249 (Assert (= (+ zero 1) 1)) |
248 (Assert (= (- zero) zero)) | 250 (Assert (= (- zero) zero)) |
249 (Assert (= (- zero) 0)) | 251 (Assert (= (- zero) 0)) |
250 (Assert (= (- zero zero) 0)) | 252 (Assert (= (- zero zero) 0)) |
251 (Assert (= (- zero one one) -2)))) | 253 (Assert (= (- zero one one) -2)))) |
252 | 254 |
253 (Assert (= (- 1.5 1) .5)) | 255 (Assert (= (- 1.5 1) .5)) |
254 (Assert (= (- 1 1.5) (- .5))) | 256 (Assert (= (- 1 1.5) (- .5))) |
255 | 257 |
258 (Assert (eq (1- most-negative-fixnum) most-positive-fixnum)) | |
259 (Assert (eq (- most-negative-fixnum 1) most-positive-fixnum)) | |
260 | |
256 ;; Test `/' | 261 ;; Test `/' |
257 | 262 |
258 ;; Test division by zero errors | 263 ;; Test division by zero errors |
259 (dolist (zero `(0 0.0 ?\0)) | 264 (dolist (zero '(0 0.0 ?\0)) |
260 (Check-Error arith-error (/ zero)) | 265 (Check-Error arith-error (/ zero)) |
261 (dolist (n1 `(42 42.0 ?\042 ,(Int-to-Marker 42))) | 266 (dolist (n1 `(42 42.0 ?\042 ,(Int-to-Marker 42))) |
262 (Check-Error arith-error (/ n1 zero)) | 267 (Check-Error arith-error (/ n1 zero)) |
263 (dolist (n2 `(3 3.0 ?\03 ,(Int-to-Marker 3))) | 268 (dolist (n2 `(3 3.0 ?\03 ,(Int-to-Marker 3))) |
264 (Check-Error arith-error (/ n1 n2 zero))))) | 269 (Check-Error arith-error (/ n1 n2 zero))))) |
267 (Check-Error wrong-number-of-arguments (/)) | 272 (Check-Error wrong-number-of-arguments (/)) |
268 (let (x) | 273 (let (x) |
269 (Assert (= (/ (setq x 2)) 0)) | 274 (Assert (= (/ (setq x 2)) 0)) |
270 (Assert (= (/ (setq x 2.0)) 0.5))) | 275 (Assert (= (/ (setq x 2.0)) 0.5))) |
271 | 276 |
272 (dolist (six `(6 6.0 ?\06)) | 277 (dolist (six '(6 6.0 ?\06)) |
273 (dolist (two `(2 2.0 ?\02)) | 278 (dolist (two '(2 2.0 ?\02)) |
274 (dolist (three `(3 3.0 ?\03)) | 279 (dolist (three '(3 3.0 ?\03)) |
275 (Assert (= (/ six two) three))))) | 280 (Assert (= (/ six two) three))))) |
276 | 281 |
277 (dolist (three `(3 3.0 ?\03)) | 282 (dolist (three '(3 3.0 ?\03)) |
278 (Assert (= (/ three 2.0) 1.5))) | 283 (Assert (= (/ three 2.0) 1.5))) |
279 (dolist (two `(2 2.0 ?\02)) | 284 (dolist (two '(2 2.0 ?\02)) |
280 (Assert (= (/ 3.0 two) 1.5))) | 285 (Assert (= (/ 3.0 two) 1.5))) |
281 | 286 |
282 ;; Test `*' | 287 ;; Test `*' |
283 (Assert (= 1 (*))) | 288 (Assert (= 1 (*))) |
284 | 289 |
285 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) | 290 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) |
286 (Assert (= 1 (* one)))) | 291 (Assert (= 1 (* one)))) |
287 | 292 |
288 (dolist (two `(2 2.0 ?\02)) | 293 (dolist (two '(2 2.0 ?\02)) |
289 (Assert (= 2 (* two)))) | 294 (Assert (= 2 (* two)))) |
290 | 295 |
291 (dolist (six `(6 6.0 ?\06)) | 296 (dolist (six '(6 6.0 ?\06)) |
292 (dolist (two `(2 2.0 ?\02)) | 297 (dolist (two '(2 2.0 ?\02)) |
293 (dolist (three `(3 3.0 ?\03)) | 298 (dolist (three '(3 3.0 ?\03)) |
294 (Assert (= (* three two) six))))) | 299 (Assert (= (* three two) six))))) |
295 | 300 |
296 (dolist (three `(3 3.0 ?\03)) | 301 (dolist (three '(3 3.0 ?\03)) |
297 (dolist (two `(2 2.0 ?\02)) | 302 (dolist (two '(2 2.0 ?\02)) |
298 (Assert (= (* 1.5 two) three)) | 303 (Assert (= (* 1.5 two) three)) |
299 (dolist (five `(5 5.0 ?\05)) | 304 (dolist (five '(5 5.0 ?\05)) |
300 (Assert (= 30 (* five two three)))))) | 305 (Assert (= 30 (* five two three)))))) |
301 | 306 |
302 ;; Test `+' | 307 ;; Test `+' |
303 (Assert (= 0 (+))) | 308 (Assert (= 0 (+))) |
304 | 309 |
305 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) | 310 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) |
306 (Assert (= 1 (+ one)))) | 311 (Assert (= 1 (+ one)))) |
307 | 312 |
308 (dolist (two `(2 2.0 ?\02)) | 313 (dolist (two '(2 2.0 ?\02)) |
309 (Assert (= 2 (+ two)))) | 314 (Assert (= 2 (+ two)))) |
310 | 315 |
311 (dolist (five `(5 5.0 ?\05)) | 316 (dolist (five '(5 5.0 ?\05)) |
312 (dolist (two `(2 2.0 ?\02)) | 317 (dolist (two '(2 2.0 ?\02)) |
313 (dolist (three `(3 3.0 ?\03)) | 318 (dolist (three '(3 3.0 ?\03)) |
314 (Assert (= (+ three two) five)) | 319 (Assert (= (+ three two) five)) |
315 (Assert (= 10 (+ five two three)))))) | 320 (Assert (= 10 (+ five two three)))))) |
316 | 321 |
317 ;; Test `max', `min' | 322 ;; Test `max', `min' |
318 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) | 323 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1))) |
339 | 344 |
340 (Check-Error wrong-type-argument (logxor 3.0)) | 345 (Check-Error wrong-type-argument (logxor 3.0)) |
341 (Check-Error wrong-type-argument (logior 3.0)) | 346 (Check-Error wrong-type-argument (logior 3.0)) |
342 (Check-Error wrong-type-argument (logand 3.0)) | 347 (Check-Error wrong-type-argument (logand 3.0)) |
343 | 348 |
344 (dolist (three `(3 ?\03)) | 349 (dolist (three '(3 ?\03)) |
345 (Assert (eq 3 (logand three))) | 350 (Assert (eq 3 (logand three))) |
346 (Assert (eq 3 (logxor three))) | 351 (Assert (eq 3 (logxor three))) |
347 (Assert (eq 3 (logior three))) | 352 (Assert (eq 3 (logior three))) |
348 (Assert (eq 3 (logand three three))) | 353 (Assert (eq 3 (logand three three))) |
349 (Assert (eq 0 (logxor three three))) | 354 (Assert (eq 0 (logxor three three))) |
350 (Assert (eq 3 (logior three three)))) | 355 (Assert (eq 3 (logior three three)))) |
351 | 356 |
352 (dolist (one `(1 ?\01 ,(Int-to-Marker 1))) | 357 (dolist (one `(1 ?\01 ,(Int-to-Marker 1))) |
353 (dolist (two `(2 ?\02)) | 358 (dolist (two '(2 ?\02)) |
354 (Assert (eq 0 (logand one two))) | 359 (Assert (eq 0 (logand one two))) |
355 (Assert (eq 3 (logior one two))) | 360 (Assert (eq 3 (logior one two))) |
356 (Assert (eq 3 (logxor one two)))) | 361 (Assert (eq 3 (logxor one two)))) |
357 (dolist (three `(3 ?\03)) | 362 (dolist (three '(3 ?\03)) |
358 (Assert (eq 1 (logand one three))) | 363 (Assert (eq 1 (logand one three))) |
359 (Assert (eq 3 (logior one three))) | 364 (Assert (eq 3 (logior one three))) |
360 (Assert (eq 2 (logxor one three))))) | 365 (Assert (eq 2 (logxor one three))))) |
361 | 366 |
362 ;;----------------------------------------------------- | 367 ;;----------------------------------------------------- |
466 (Check-Error wrong-type-argument (> 'foo 1)) | 471 (Check-Error wrong-type-argument (> 'foo 1)) |
467 (Check-Error wrong-type-argument (/= 'foo 1)) | 472 (Check-Error wrong-type-argument (/= 'foo 1)) |
468 | 473 |
469 ;; Meat | 474 ;; Meat |
470 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01)) | 475 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01)) |
471 (dolist (two `(2 2.0 ?\02)) | 476 (dolist (two '(2 2.0 ?\02)) |
472 (Assert (< one two)) | 477 (Assert (< one two)) |
473 (Assert (<= one two)) | 478 (Assert (<= one two)) |
474 (Assert (<= two two)) | 479 (Assert (<= two two)) |
475 (Assert (> two one)) | 480 (Assert (> two one)) |
476 (Assert (>= two one)) | 481 (Assert (>= two one)) |
487 (Assert (not (= one one one two))) | 492 (Assert (not (= one one one two))) |
488 (Assert (not (/= one two one))) | 493 (Assert (not (/= one two one))) |
489 )) | 494 )) |
490 | 495 |
491 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01)) | 496 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01)) |
492 (dolist (two `(2 2.0 ?\02)) | 497 (dolist (two '(2 2.0 ?\02)) |
493 (Assert (< one two)) | 498 (Assert (< one two)) |
494 (Assert (<= one two)) | 499 (Assert (<= one two)) |
495 (Assert (<= two two)) | 500 (Assert (<= two two)) |
496 (Assert (> two one)) | 501 (Assert (> two one)) |
497 (Assert (>= two one)) | 502 (Assert (>= two one)) |
535 (fun) | 540 (fun) |
536 `(progn | 541 `(progn |
537 (Check-Error wrong-number-of-arguments (,fun)) | 542 (Check-Error wrong-number-of-arguments (,fun)) |
538 (Check-Error wrong-number-of-arguments (,fun nil)) | 543 (Check-Error wrong-number-of-arguments (,fun nil)) |
539 (Check-Error malformed-list (,fun nil 1)) | 544 (Check-Error malformed-list (,fun nil 1)) |
540 ,@(loop for n in `(1 2 2000) | 545 ,@(loop for n in '(1 2 2000) |
541 collect `(Check-Error circular-list (,fun 1 (make-circular-list ,n)))))) | 546 collect `(Check-Error circular-list (,fun 1 (make-circular-list ,n)))))) |
542 (test-funs (&rest funs) `(progn ,@(loop for fun in funs collect `(test-fun ,fun))))) | 547 (test-funs (&rest funs) `(progn ,@(loop for fun in funs collect `(test-fun ,fun))))) |
543 | 548 |
544 (test-funs member old-member | 549 (test-funs member old-member |
545 memq old-memq | 550 memq old-memq |
748 | 753 |
749 (Check-Error wrong-type-argument (mapconcat #'identity (current-buffer) "foo")) | 754 (Check-Error wrong-type-argument (mapconcat #'identity (current-buffer) "foo")) |
750 (Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3")) | 755 (Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3")) |
751 (Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3")) | 756 (Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3")) |
752 | 757 |
758 ;; The following 2 functions used to crash XEmacs via mapcar1(). | |
759 ;; We don't test the actual values of the mapcar, since they're undefined. | |
760 (Assert | |
761 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) | |
762 (mapcar | |
763 (lambda (y) | |
764 "Devious evil mapping function" | |
765 (when (eq (car y) 2) ; go out onto a limb | |
766 (setcdr x nil) ; cut it off behind us | |
767 (garbage-collect)) ; are we riding a magic broomstick? | |
768 (car y)) ; sorry, hard landing | |
769 x))) | |
770 | |
771 (Assert | |
772 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) | |
773 (mapcar | |
774 (lambda (y) | |
775 "Devious evil mapping function" | |
776 (when (eq (car y) 1) | |
777 (setcdr (cdr x) 42)) ; drop a brick wall onto the freeway | |
778 (car y)) | |
779 x))) | |
780 | |
753 ;;----------------------------------------------------- | 781 ;;----------------------------------------------------- |
754 ;; Test vector functions | 782 ;; Test vector functions |
755 ;;----------------------------------------------------- | 783 ;;----------------------------------------------------- |
756 (Assert (equal [1 2 3] [1 2 3])) | 784 (Assert (equal [1 2 3] [1 2 3])) |
757 (Assert (equal [] [])) | 785 (Assert (equal [] [])) |
783 (make-local-variable 'test-emacs-buffer-local-variable) | 811 (make-local-variable 'test-emacs-buffer-local-variable) |
784 (byte-compile | 812 (byte-compile |
785 (defun test-emacs-buffer-local-parameter (test-emacs-buffer-local-variable) | 813 (defun test-emacs-buffer-local-parameter (test-emacs-buffer-local-variable) |
786 (setq test-emacs-buffer-local-variable nil))) | 814 (setq test-emacs-buffer-local-variable nil))) |
787 (test-emacs-buffer-local-parameter nil) | 815 (test-emacs-buffer-local-parameter nil) |
816 | |
817 ;;----------------------------------------------------- | |
818 ;; Test split-string | |
819 ;;----------------------------------------------------- | |
820 ;; Hrvoje didn't like these tests so I'm disabling them for now. -sb | |
821 ;(Assert (equal (split-string "foo" "") '("" "f" "o" "o" ""))) | |
822 ;(Assert (equal (split-string "foo" "^") '("" "foo"))) | |
823 ;(Assert (equal (split-string "foo" "$") '("foo" ""))) | |
824 (Assert (equal (split-string "foo,bar" ",") '("foo" "bar"))) | |
825 (Assert (equal (split-string ",foo,bar," ",") '("" "foo" "bar" ""))) | |
826 (Assert (equal (split-string ",foo,bar," "^,") '("" "foo,bar,"))) | |
827 (Assert (equal (split-string ",foo,bar," ",$") '(",foo,bar" ""))) | |
828 (Assert (equal (split-string ",foo,,bar," ",") '("" "foo" "" "bar" ""))) | |
829 (Assert (equal (split-string "foo,,,bar" ",") '("foo" "" "" "bar"))) | |
830 (Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" ""))) | |
831 (Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar"))) | |
832 (Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" ""))) | |
833 | |
834 ;;----------------------------------------------------- | |
835 ;; Test near-text buffer functions. | |
836 ;;----------------------------------------------------- | |
837 (with-temp-buffer | |
838 (erase-buffer) | |
839 (Assert (eq (char-before) nil)) | |
840 (Assert (eq (char-before (point)) nil)) | |
841 (Assert (eq (char-before (point-marker)) nil)) | |
842 (Assert (eq (char-before (point) (current-buffer)) nil)) | |
843 (Assert (eq (char-before (point-marker) (current-buffer)) nil)) | |
844 (Assert (eq (char-after) nil)) | |
845 (Assert (eq (char-after (point)) nil)) | |
846 (Assert (eq (char-after (point-marker)) nil)) | |
847 (Assert (eq (char-after (point) (current-buffer)) nil)) | |
848 (Assert (eq (char-after (point-marker) (current-buffer)) nil)) | |
849 (Assert (eq (preceding-char) 0)) | |
850 (Assert (eq (preceding-char (current-buffer)) 0)) | |
851 (Assert (eq (following-char) 0)) | |
852 (Assert (eq (following-char (current-buffer)) 0)) | |
853 (insert "foobar") | |
854 (Assert (eq (char-before) ?r)) | |
855 (Assert (eq (char-after) nil)) | |
856 (Assert (eq (preceding-char) ?r)) | |
857 (Assert (eq (following-char) 0)) | |
858 (goto-char (point-min)) | |
859 (Assert (eq (char-before) nil)) | |
860 (Assert (eq (char-after) ?f)) | |
861 (Assert (eq (preceding-char) 0)) | |
862 (Assert (eq (following-char) ?f)) | |
863 ) | |
864 | |
865 ;;----------------------------------------------------- | |
866 ;; Test plist manipulation functions. | |
867 ;;----------------------------------------------------- | |
868 (let ((sym (make-symbol "test-symbol"))) | |
869 (Assert (eq t (get* sym t t))) | |
870 (Assert (eq t (get sym t t))) | |
871 (Assert (eq t (getf nil t t))) | |
872 (Assert (eq t (plist-get nil t t))) | |
873 (put sym 'bar 'baz) | |
874 (Assert (eq 'baz (get sym 'bar))) | |
875 (Assert (eq 'baz (getf '(bar baz) 'bar))) | |
876 (Assert (eq 'baz (getf (symbol-plist sym) 'bar))) | |
877 (Assert (eq 2 (getf '(1 2) 1))) | |
878 (Assert (eq 4 (put sym 3 4))) | |
879 (Assert (eq 4 (get sym 3))) | |
880 (Assert (eq t (remprop sym 3))) | |
881 (Assert (eq nil (remprop sym 3))) | |
882 (Assert (eq 5 (get sym 3 5))) | |
883 ) | |
884 | |
885 (loop for obj in | |
886 (list (make-symbol "test-symbol") | |
887 "test-string" | |
888 (make-extent nil nil nil) | |
889 (make-face 'test-face)) | |
890 do | |
891 (Assert (eq 2 (get obj ?1 2))) | |
892 (Assert (eq 4 (put obj ?3 4))) | |
893 (Assert (eq 4 (get obj ?3))) | |
894 (when (or (stringp obj) (symbolp obj)) | |
895 (Assert (equal '(?3 4) (object-plist obj)))) | |
896 (Assert (eq t (remprop obj ?3))) | |
897 (when (or (stringp obj) (symbolp obj)) | |
898 (Assert (eq '() (object-plist obj)))) | |
899 (Assert (eq nil (remprop obj ?3))) | |
900 (when (or (stringp obj) (symbolp obj)) | |
901 (Assert (eq '() (object-plist obj)))) | |
902 (Assert (eq 5 (get obj ?3 5))) | |
903 ) | |
904 | |
905 (Check-Error-Message | |
906 error "Object type has no properties" | |
907 (get 2 'property)) | |
908 | |
909 (Check-Error-Message | |
910 error "Object type has no settable properties" | |
911 (put (current-buffer) 'property 'value)) | |
912 | |
913 (Check-Error-Message | |
914 error "Object type has no removable properties" | |
915 (remprop ?3 'property)) | |
916 | |
917 (Check-Error-Message | |
918 error "Object type has no properties" | |
919 (object-plist (symbol-function 'car))) | |
920 | |
921 (Check-Error-Message | |
922 error "Can't remove property from object" | |
923 (remprop (make-extent nil nil nil) 'detachable)) | |
924 | |
925 ;;----------------------------------------------------- | |
926 ;; Test subseq | |
927 ;;----------------------------------------------------- | |
928 (Assert (equal (subseq nil 0) nil)) | |
929 (Assert (equal (subseq [1 2 3] 0) [1 2 3])) | |
930 (Assert (equal (subseq [1 2 3] 1 -1) [2])) | |
931 (Assert (equal (subseq "123" 0) "123")) | |
932 (Assert (equal (subseq "1234" -3 -1) "23")) | |
933 (Assert (equal (subseq #*0011 0) #*0011)) | |
934 (Assert (equal (subseq #*0011 -3 3) #*01)) | |
935 (Assert (equal (subseq '(1 2 3) 0) '(1 2 3))) | |
936 (Assert (equal (subseq '(1 2 3 4) -3 nil) '(2 3 4))) | |
937 | |
938 (Check-Error 'wrong-type-argument (subseq 3 2)) | |
939 (Check-Error 'args-out-of-range (subseq [1 2 3] -42)) | |
940 (Check-Error 'args-out-of-range (subseq [1 2 3] 0 42)) |