Mercurial > hg > xemacs-beta
comparison tests/automated/lisp-tests.el @ 446:1ccc32a20af4 r21-2-38
Import from CVS: tag r21-2-38
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:37:21 +0200 |
parents | 576fb035e263 |
children | 3078fd1074e8 |
comparison
equal
deleted
inserted
replaced
445:34f3776fcf0e | 446:1ccc32a20af4 |
---|---|
332 (Assert (= one (min one two two))) | 332 (Assert (= one (min one two two))) |
333 (Assert (= one (min two two one))) | 333 (Assert (= one (min two two one))) |
334 (Assert (= two (max one two))) | 334 (Assert (= two (max one two))) |
335 (Assert (= two (max one two two))) | 335 (Assert (= two (max one two two))) |
336 (Assert (= two (max two two one))))) | 336 (Assert (= two (max two two one))))) |
337 | |
338 ;; The byte compiler has special handling for these constructs: | |
339 (let ((three 3) (five 5)) | |
340 (Assert (= (+ three five 1) 9)) | |
341 (Assert (= (+ 1 three five) 9)) | |
342 (Assert (= (+ three five -1) 7)) | |
343 (Assert (= (+ -1 three five) 7)) | |
344 (Assert (= (+ three 1) 4)) | |
345 (Assert (= (+ three -1) 2)) | |
346 (Assert (= (+ -1 three) 2)) | |
347 (Assert (= (+ -1 three) 2)) | |
348 (Assert (= (- three five 1) -3)) | |
349 (Assert (= (- 1 three five) -7)) | |
350 (Assert (= (- three five -1) -1)) | |
351 (Assert (= (- -1 three five) -9)) | |
352 (Assert (= (- three 1) 2)) | |
353 (Assert (= (- three 2 1) 0)) | |
354 (Assert (= (- 2 three 1) -2)) | |
355 (Assert (= (- three -1) 4)) | |
356 (Assert (= (- three 0) 3)) | |
357 (Assert (= (- three 0 five) -2)) | |
358 (Assert (= (- 0 three 0 five) -8)) | |
359 (Assert (= (- 0 three five) -8)) | |
360 (Assert (= (* three 2) 6)) | |
361 (Assert (= (* three -1 five) -15)) | |
362 (Assert (= (* three 1 five) 15)) | |
363 (Assert (= (* three 0 five) 0)) | |
364 (Assert (= (* three 2 five) 30)) | |
365 (Assert (= (/ three 1) 3)) | |
366 (Assert (= (/ three -1) -3)) | |
367 (Assert (= (/ (* five five) 2 2) 6)) | |
368 (Assert (= (/ 64 five 2) 6))) | |
369 | |
337 | 370 |
338 ;;----------------------------------------------------- | 371 ;;----------------------------------------------------- |
339 ;; Logical bit-twiddling operations | 372 ;; Logical bit-twiddling operations |
340 ;;----------------------------------------------------- | 373 ;;----------------------------------------------------- |
341 (Assert (= (logxor) 0)) | 374 (Assert (= (logxor) 0)) |
755 (Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3")) | 788 (Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3")) |
756 (Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3")) | 789 (Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3")) |
757 | 790 |
758 ;; The following 2 functions used to crash XEmacs via mapcar1(). | 791 ;; 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. | 792 ;; We don't test the actual values of the mapcar, since they're undefined. |
760 (Assert | 793 (Assert |
761 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) | 794 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) |
762 (mapcar | 795 (mapcar |
763 (lambda (y) | 796 (lambda (y) |
764 "Devious evil mapping function" | 797 "Devious evil mapping function" |
765 (when (eq (car y) 2) ; go out onto a limb | 798 (when (eq (car y) 2) ; go out onto a limb |
766 (setcdr x nil) ; cut it off behind us | 799 (setcdr x nil) ; cut it off behind us |
767 (garbage-collect)) ; are we riding a magic broomstick? | 800 (garbage-collect)) ; are we riding a magic broomstick? |
768 (car y)) ; sorry, hard landing | 801 (car y)) ; sorry, hard landing |
769 x))) | 802 x))) |
770 | 803 |
771 (Assert | 804 (Assert |
772 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) | 805 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3)))) |
773 (mapcar | 806 (mapcar |
774 (lambda (y) | 807 (lambda (y) |
775 "Devious evil mapping function" | 808 "Devious evil mapping function" |
776 (when (eq (car y) 1) | 809 (when (eq (car y) 1) |
830 (Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" ""))) | 863 (Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" ""))) |
831 (Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar"))) | 864 (Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar"))) |
832 (Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" ""))) | 865 (Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" ""))) |
833 | 866 |
834 (Assert (not (string-match "\\(\\.\\=\\)" "."))) | 867 (Assert (not (string-match "\\(\\.\\=\\)" "."))) |
835 (Assert (string= "" (let ((str "test string")) | 868 (Assert (string= "" (let ((str "test string")) |
836 (if (string-match "^.*$" str) | 869 (if (string-match "^.*$" str) |
837 (replace-match "\\U" t nil str))))) | 870 (replace-match "\\U" t nil str))))) |
838 (with-temp-buffer | 871 (with-temp-buffer |
839 (erase-buffer) | 872 (erase-buffer) |
840 (insert "test string") | 873 (insert "test string") |
944 (Assert (equal (subseq #*0011 0) #*0011)) | 977 (Assert (equal (subseq #*0011 0) #*0011)) |
945 (Assert (equal (subseq #*0011 -3 3) #*01)) | 978 (Assert (equal (subseq #*0011 -3 3) #*01)) |
946 (Assert (equal (subseq '(1 2 3) 0) '(1 2 3))) | 979 (Assert (equal (subseq '(1 2 3) 0) '(1 2 3))) |
947 (Assert (equal (subseq '(1 2 3 4) -3 nil) '(2 3 4))) | 980 (Assert (equal (subseq '(1 2 3 4) -3 nil) '(2 3 4))) |
948 | 981 |
949 (Check-Error 'wrong-type-argument (subseq 3 2)) | 982 (Check-Error wrong-type-argument (subseq 3 2)) |
950 (Check-Error 'args-out-of-range (subseq [1 2 3] -42)) | 983 (Check-Error args-out-of-range (subseq [1 2 3] -42)) |
951 (Check-Error 'args-out-of-range (subseq [1 2 3] 0 42)) | 984 (Check-Error args-out-of-range (subseq [1 2 3] 0 42)) |
952 | 985 |
953 ;;----------------------------------------------------- | 986 ;;----------------------------------------------------- |
954 ;; Time-related tests | 987 ;; Time-related tests |
955 ;;----------------------------------------------------- | 988 ;;----------------------------------------------------- |
956 (Assert (= (length (current-time-string)) 24)) | 989 (Assert (= (length (current-time-string)) 24)) |
1021 (Assert (string= (format "%01.1d" 10) "10")) | 1054 (Assert (string= (format "%01.1d" 10) "10")) |
1022 (Assert (string= (format "%03.1d" 10) "010")) | 1055 (Assert (string= (format "%03.1d" 10) "010")) |
1023 (Assert (string= (format "%01.3d" 10) "10")) | 1056 (Assert (string= (format "%01.3d" 10) "10")) |
1024 (Assert (string= (format "%1.3d" 10) "10")) | 1057 (Assert (string= (format "%1.3d" 10) "10")) |
1025 (Assert (string= (format "%3.1d" 10) " 10")) | 1058 (Assert (string= (format "%3.1d" 10) " 10")) |
1059 | |
1060 ;;; Check for 64-bit cleanness on LP64 platforms. | |
1061 (Assert (= (read (format "%d" most-positive-fixnum)) most-positive-fixnum)) | |
1062 (Assert (= (read (format "%ld" most-positive-fixnum)) most-positive-fixnum)) | |
1063 (Assert (= (read (format "%u" most-positive-fixnum)) most-positive-fixnum)) | |
1064 (Assert (= (read (format "%lu" most-positive-fixnum)) most-positive-fixnum)) | |
1065 (Assert (= (read (format "%d" most-negative-fixnum)) most-negative-fixnum)) | |
1066 (Assert (= (read (format "%ld" most-negative-fixnum)) most-negative-fixnum)) | |
1067 | |
1068 ;;; "%u" is undocumented, and Emacs Lisp has no unsigned type. | |
1069 ;;; What to do if "%u" is used with a negative number? | |
1070 ;;; The most reasonable thing seems to be to print an un-read-able number. | |
1071 ;;; The printed value might be useful to a human, if not to Emacs Lisp. | |
1072 (Check-Error invalid-read-syntax (read (format "%u" most-negative-fixnum))) | |
1073 (Check-Error invalid-read-syntax (read (format "%u" -1))) |