annotate tests/automated/lisp-tests.el @ 4465:732b87cfabf2

Document Win32 symlink behaviour; adjust tests to take it into a/c. src/ChangeLog addition: 2008-05-21 Aidan Kehoe <kehoea@parhasard.net> * fileio.c (Fmake_symbolic_link): Document behaviour when the underlying OS doesn't support symbolic links. tests/ChangeLog addition: 2008-05-21 Aidan Kehoe <kehoea@parhasard.net> * automated/mule-tests.el (featurep): Make sure that working symlinks are available before testing their functionality. Also, don't bomb out on deleting the other temporary files if deleting the first threw an error.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 21 May 2008 16:55:14 +0200
parents e97f16fb2e25
children eecd28508f4a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;; Copyright (C) 1998 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Author: Martin Buchholz <martin@xemacs.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Maintainer: Martin Buchholz <martin@xemacs.org>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Created: 1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Keywords: tests
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;; Test basic Lisp engine functionality
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;;; See test-harness.el for instructions on how to run these tests.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 (eval-when-compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 (condition-case nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 (require 'test-harness)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 (file-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 (push "." load-path)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 (when (and (boundp 'load-file-name) (stringp load-file-name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 (push (file-name-directory load-file-name) load-path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 (require 'test-harness))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (Check-Error wrong-number-of-arguments (setq setq-test-foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (Check-Error wrong-number-of-arguments (setq setq-test-foo 1 setq-test-bar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 (Check-Error wrong-number-of-arguments (setq-default setq-test-foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (Check-Error wrong-number-of-arguments (setq-default setq-test-foo 1 setq-test-bar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 (Assert (eq (setq) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (Assert (eq (setq-default) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (Assert (eq (setq setq-test-foo 42) 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (Assert (eq (setq-default setq-test-foo 42) 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (Assert (eq (setq setq-test-foo 42 setq-test-bar 99) 99))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (Assert (eq (setq-default setq-test-foo 42 setq-test-bar 99) 99))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 (macrolet ((test-setq (expected-result &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 `(progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (defun test-setq-fun () ,@body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (Assert (eq ,expected-result (test-setq-fun)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (byte-compile 'test-setq-fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (Assert (eq ,expected-result (test-setq-fun))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (test-setq nil (setq))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (test-setq nil (setq-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (test-setq 42 (setq test-setq-var 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (test-setq 42 (setq-default test-setq-var 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (test-setq 42 (setq test-setq-bar 99 test-setq-var 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (test-setq 42 (setq-default test-setq-bar 99 test-setq-var 42))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (let ((my-vector [1 2 3 4])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (my-bit-vector (bit-vector 1 0 1 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 (my-string "1234")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (my-list '(1 2 3 4)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 ;;(Assert (fooooo)) ;; Generate Other failure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 ;;(Assert (eq 1 2)) ;; Generate Assertion failure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (dolist (sequence (list my-vector my-bit-vector my-string my-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (Assert (sequencep sequence))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (Assert (eq 4 (length sequence))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (dolist (array (list my-vector my-bit-vector my-string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (Assert (arrayp array)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (Assert (eq (elt my-vector 0) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (Assert (eq (elt my-bit-vector 0) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (Assert (eq (elt my-string 0) ?1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 (Assert (eq (elt my-list 0) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (fillarray my-vector 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (fillarray my-bit-vector 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (fillarray my-string ?5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (dolist (array (list my-vector my-bit-vector))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (Assert (eq 4 (length array))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (Assert (eq (elt my-vector 0) 5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (Assert (eq (elt my-bit-vector 0) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (Assert (eq (elt my-string 0) ?5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (Assert (eq (elt my-vector 3) 5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 (Assert (eq (elt my-bit-vector 3) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (Assert (eq (elt my-string 3) ?5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (fillarray my-bit-vector 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (Assert (eq 4 (length my-bit-vector)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (Assert (eq (elt my-bit-vector 2) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (defun make-circular-list (length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 "Create evil emacs-crashing circular list of length LENGTH"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (let ((circular-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (make-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 length
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 'you-are-trapped-in-a-twisty-maze-of-cons-cells-all-alike)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (setcdr (last circular-list) circular-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 circular-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 ;; Test `nconc'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (defun make-list-012 () (list 0 1 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (Check-Error wrong-type-argument (nconc 'foo nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (dolist (length '(1 2 3 4 1000 2000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 (Check-Error circular-list (nconc (make-circular-list length) 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (Check-Error circular-list (nconc '(1 . 2) (make-circular-list length) 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (Check-Error circular-list (nconc '(1 . 2) '(3 . 4) (make-circular-list length) 'foo)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (Assert (eq (nconc) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (Assert (eq (nconc nil) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (Assert (eq (nconc nil nil) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (Assert (eq (nconc nil nil nil) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (let ((x (make-list-012))) (Assert (eq (nconc nil x) x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (let ((x (make-list-012))) (Assert (eq (nconc x nil) x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 (let ((x (make-list-012))) (Assert (eq (nconc nil x nil) x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (let ((x (make-list-012))) (Assert (eq (nconc x) x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (let ((x (make-list-012))) (Assert (eq (nconc x (make-circular-list 3)) x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 (Assert (equal (nconc '(1 . 2) '(3 . 4) '(5 . 6)) '(1 3 5 . 6)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (let ((y (nconc (make-list-012) nil (list 3 4 5) nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (Assert (eq (length y) 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (Assert (eq (nth 3 y) 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 ;; Test `last'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (Check-Error wrong-type-argument (last 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (Check-Error wrong-number-of-arguments (last))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (Check-Error wrong-number-of-arguments (last '(1 2) 1 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (Check-Error circular-list (last (make-circular-list 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (Check-Error circular-list (last (make-circular-list 2000)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (let ((x (list 0 1 2 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (Assert (eq (last nil) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (Assert (eq (last x 0) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (Assert (eq (last x ) (cdddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (Assert (eq (last x 1) (cdddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (Assert (eq (last x 2) (cddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (Assert (eq (last x 3) (cdr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (Assert (eq (last x 4) x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (Assert (eq (last x 9) x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (Assert (eq (last '(1 . 2) 0) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ;; Test `butlast' and `nbutlast'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (Check-Error wrong-type-argument (butlast 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (Check-Error wrong-type-argument (nbutlast 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (Check-Error wrong-number-of-arguments (butlast))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (Check-Error wrong-number-of-arguments (nbutlast))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (Check-Error wrong-number-of-arguments (butlast '(1 2) 1 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (Check-Error wrong-number-of-arguments (nbutlast '(1 2) 1 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (Check-Error circular-list (butlast (make-circular-list 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (Check-Error circular-list (nbutlast (make-circular-list 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (Check-Error circular-list (butlast (make-circular-list 2000)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (Check-Error circular-list (nbutlast (make-circular-list 2000)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (let* ((x (list 0 1 2 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (y (butlast x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (z (nbutlast x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (Assert (eq z x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (Assert (not (eq y x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (Assert (equal y '(0 1 2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (Assert (equal z y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (let* ((x (list 0 1 2 3 4))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (y (butlast x 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (z (nbutlast x 2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (Assert (eq z x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (Assert (not (eq y x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (Assert (equal y '(0 1 2)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (Assert (equal z y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (let* ((x (list 0 1 2 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (y (butlast x 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (z (nbutlast x 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (Assert (eq z x))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (Assert (not (eq y x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (Assert (equal y '(0 1 2 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (Assert (equal z y)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (Assert (eq (butlast '(x)) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (Assert (eq (nbutlast '(x)) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (Assert (eq (butlast '()) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (Assert (eq (nbutlast '()) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 ;; Test `copy-list'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (Check-Error wrong-type-argument (copy-list 'foo))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (Check-Error wrong-number-of-arguments (copy-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (Check-Error wrong-number-of-arguments (copy-list '(1 2) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (Check-Error circular-list (copy-list (make-circular-list 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (Check-Error circular-list (copy-list (make-circular-list 2000)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (Assert (eq '() (copy-list '())))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (dolist (x '((1) (1 2) (1 2 3) (1 2 . 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (let ((y (copy-list x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (Assert (and (equal x y) (not (eq x y))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 ;; Arithmetic operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 ;; Test `+'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (Assert (eq (+ 1 1) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (Assert (= (+ 1.0 1.0) 2.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (Assert (= (+ 1.0 3.0 0.0) 4.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (Assert (= (+ 1 1.0) 2.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (Assert (= (+ 1.0 1) 2.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (Assert (= (+ 1.0 1 1) 3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (Assert (= (+ 1 1 1.0) 3.0))
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
232 (if (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
233 (progn
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
234 (Assert (bignump (1+ most-positive-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
235 (Assert (eq most-positive-fixnum (1- (1+ most-positive-fixnum))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
236 (Assert (bignump (+ most-positive-fixnum 1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
237 (Assert (eq most-positive-fixnum (- (+ most-positive-fixnum 1) 1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
238 (Assert (= (1+ most-positive-fixnum) (- most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
239 (Assert (zerop (+ (* 3 most-negative-fixnum) (* 3 most-positive-fixnum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
240 3))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
241 (Assert (eq (1+ most-positive-fixnum) most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
242 (Assert (eq (+ most-positive-fixnum 1) most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
243
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
244 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
245 (let ((threefourths (read "3/4"))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
246 (threehalfs (read "3/2"))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
247 (bigpos (div (+ most-positive-fixnum 2) (1+ most-positive-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
248 (bigneg (div (+ most-positive-fixnum 2) most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
249 (negone (div (1+ most-positive-fixnum) most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
250 (Assert (= negone -1))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
251 (Assert (= threehalfs (+ threefourths threefourths)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
252 (Assert (zerop (+ bigpos bigneg)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 ;; Test `-'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (Check-Error wrong-number-of-arguments (-))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (Assert (eq (- 0) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (Assert (eq (- 1) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (dolist (one `(1 1.0 ?\1 ,(Int-to-Marker 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (Assert (= (+ 1 one) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 (Assert (= (+ one) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (Assert (= (+ one) one))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (Assert (= (- one) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (Assert (= (- one one) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (Assert (= (- one one one) -1))
464
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 448
diff changeset
265 (Assert (= (- 0 one) -1))
5aa1854ad537 Import from CVS: tag r21-2-47
cvs
parents: 448
diff changeset
266 (Assert (= (- 0 one one) -2))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 (Assert (= (+ one 1) 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (dolist (zero '(0 0.0 ?\0))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
269 (Assert (= (+ 1 zero) 1) zero)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
270 (Assert (= (+ zero 1) 1) zero)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
271 (Assert (= (- zero) zero) zero)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
272 (Assert (= (- zero) 0) zero)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
273 (Assert (= (- zero zero) 0) zero)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
274 (Assert (= (- zero one one) -2) zero)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 (Assert (= (- 1.5 1) .5))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (Assert (= (- 1 1.5) (- .5)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
279 (if (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
280 (progn
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
281 (Assert (bignump (1- most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
282 (Assert (eq most-negative-fixnum (1+ (1- most-negative-fixnum))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
283 (Assert (bignump (- most-negative-fixnum 1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
284 (Assert (eq most-negative-fixnum (+ (- most-negative-fixnum 1) 1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
285 (Assert (= (1- most-negative-fixnum) (- 0 most-positive-fixnum 2)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
286 (Assert (eq (- (- most-positive-fixnum most-negative-fixnum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
287 (* 2 most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
288 1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
289 (Assert (eq (1- most-negative-fixnum) most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
290 (Assert (eq (- most-negative-fixnum 1) most-positive-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
291
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
292 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
293 (let ((threefourths (read "3/4"))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
294 (threehalfs (read "3/2"))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
295 (bigpos (div (+ most-positive-fixnum 2) (1+ most-positive-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
296 (bigneg (div most-positive-fixnum most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
297 (negone (div (1+ most-positive-fixnum) most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
298 (Assert (= (- negone) 1))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
299 (Assert (= threefourths (- threehalfs threefourths)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
300 (Assert (= (- bigpos bigneg) 2))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 ;; Test `/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 ;; Test division by zero errors
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 (dolist (zero '(0 0.0 ?\0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (Check-Error arith-error (/ zero))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (dolist (n1 `(42 42.0 ?\042 ,(Int-to-Marker 42)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (Check-Error arith-error (/ n1 zero))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (dolist (n2 `(3 3.0 ?\03 ,(Int-to-Marker 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (Check-Error arith-error (/ n1 n2 zero)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 ;; Other tests for `/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (Check-Error wrong-number-of-arguments (/))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (let (x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (Assert (= (/ (setq x 2)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 (Assert (= (/ (setq x 2.0)) 0.5)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (dolist (six '(6 6.0 ?\06))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 (dolist (two '(2 2.0 ?\02))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (dolist (three '(3 3.0 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
321 (Assert (= (/ six two) three) (list six two three)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (dolist (three '(3 3.0 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
324 (Assert (= (/ three 2.0) 1.5) three))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
326 (Assert (= (/ 3.0 two) 1.5) two))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
328 (when (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
329 (let* ((million 1000000)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
330 (billion (* million 1000)) ;; American, not British, billion
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
331 (trillion (* billion 1000)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
332 (Assert (= (/ billion 1000) (/ trillion million) million 1000000.0))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
333 (Assert (= (/ billion -1000) (/ trillion (- million)) (- million)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
334 (Assert (= (/ trillion 1000) billion 1000000000.0))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
335 (Assert (= (/ trillion -1000) (- billion) -1000000000.0))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
336 (Assert (= (/ trillion 10) (* 100 billion) 100000000000.0))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
337 (Assert (= (/ (- trillion) 10) (* -100 billion) -100000000000.0))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
338
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
339 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
340 (let ((half (div 1 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
341 (fivefourths (div 5 4))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
342 (fivehalfs (div 5 2)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
343 (Assert (= half (read "3000000000/6000000000")))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
344 (Assert (= (/ fivehalfs fivefourths) 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
345 (Assert (= (/ fivefourths fivehalfs) half))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
346 (Assert (= (- half) (read "-3000000000/6000000000")))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
347 (Assert (= (/ fivehalfs (- fivefourths)) -2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
348 (Assert (= (/ (- fivefourths) fivehalfs) (- half)))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
349
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 ;; Test `*'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (Assert (= 1 (*)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1)))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
354 (Assert (= 1 (* one)) one))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
357 (Assert (= 2 (* two)) two))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (dolist (six '(6 6.0 ?\06))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (dolist (two '(2 2.0 ?\02))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (dolist (three '(3 3.0 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
362 (Assert (= (* three two) six) (list three two six)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (dolist (three '(3 3.0 ?\03))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
366 (Assert (= (* 1.5 two) three) (list two three))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (dolist (five '(5 5.0 ?\05))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
368 (Assert (= 30 (* five two three)) (list five two three)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
370 (when (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
371 (let ((64K 65536))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
372 (Assert (= (* 64K 64K) (read "4294967296")))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
373 (Assert (= (* (- 64K) 64K) (read "-4294967296")))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
374 (Assert (/= (* -1 most-negative-fixnum) most-negative-fixnum))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
375
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
376 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
377 (let ((half (div 1 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
378 (fivefourths (div 5 4))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
379 (twofifths (div 2 5)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
380 (Assert (= (* fivefourths twofifths) half))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
381 (Assert (= (* half twofifths) (read "3/15")))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
382
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; Test `+'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 (Assert (= 0 (+)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1)))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
387 (Assert (= 1 (+ one)) one))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
390 (Assert (= 2 (+ two)) two))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 (dolist (five '(5 5.0 ?\05))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 (dolist (two '(2 2.0 ?\02))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (dolist (three '(3 3.0 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
395 (Assert (= (+ three two) five) (list three two five))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
396 (Assert (= 10 (+ five two three)) (list five two three)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 ;; Test `max', `min'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (dolist (one `(1 1.0 ?\01 ,(Int-to-Marker 1)))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
400 (Assert (= one (max one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
401 (Assert (= one (max one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
402 (Assert (= one (max one one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
403 (Assert (= one (min one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
404 (Assert (= one (min one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
405 (Assert (= one (min one one one)) one)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 (dolist (two `(2 2.0 ?\02 ,(Int-to-Marker 2)))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
407 (Assert (= one (min one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
408 (Assert (= one (min one two two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
409 (Assert (= one (min two two one)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
410 (Assert (= two (max one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
411 (Assert (= two (max one two two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
412 (Assert (= two (max two two one)) (list one two))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
414 (when (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
415 (let ((big (1+ most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
416 (small (1- most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
417 (Assert (= big (max 1 1000000.0 most-positive-fixnum big)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
418 (Assert (= small (min -1 -1000000.0 most-negative-fixnum small)))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
419
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
420 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
421 (let* ((big (1+ most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
422 (small (1- most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
423 (bigr (div (* 5 (1+ most-positive-fixnum)) 4))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
424 (smallr (- bigr)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
425 (Assert (= bigr (max 1 1000000.0 most-positive-fixnum big bigr)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
426 (Assert (= smallr (min -1 -1000000.0 most-negative-fixnum small smallr)))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
427
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
428 ;; The byte compiler has special handling for these constructs:
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
429 (let ((three 3) (five 5))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
430 (Assert (= (+ three five 1) 9))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
431 (Assert (= (+ 1 three five) 9))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
432 (Assert (= (+ three five -1) 7))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
433 (Assert (= (+ -1 three five) 7))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
434 (Assert (= (+ three 1) 4))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
435 (Assert (= (+ three -1) 2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
436 (Assert (= (+ -1 three) 2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
437 (Assert (= (+ -1 three) 2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
438 (Assert (= (- three five 1) -3))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
439 (Assert (= (- 1 three five) -7))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
440 (Assert (= (- three five -1) -1))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
441 (Assert (= (- -1 three five) -9))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
442 (Assert (= (- three 1) 2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
443 (Assert (= (- three 2 1) 0))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
444 (Assert (= (- 2 three 1) -2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
445 (Assert (= (- three -1) 4))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
446 (Assert (= (- three 0) 3))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
447 (Assert (= (- three 0 five) -2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
448 (Assert (= (- 0 three 0 five) -8))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
449 (Assert (= (- 0 three five) -8))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
450 (Assert (= (* three 2) 6))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
451 (Assert (= (* three -1 five) -15))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
452 (Assert (= (* three 1 five) 15))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
453 (Assert (= (* three 0 five) 0))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
454 (Assert (= (* three 2 five) 30))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
455 (Assert (= (/ three 1) 3))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
456 (Assert (= (/ three -1) -3))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
457 (Assert (= (/ (* five five) 2 2) 6))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
458 (Assert (= (/ 64 five 2) 6)))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
459
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
460
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 ;; Logical bit-twiddling operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (Assert (= (logxor) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (Assert (= (logior) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (Assert (= (logand) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 (Check-Error wrong-type-argument (logxor 3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (Check-Error wrong-type-argument (logior 3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 (Check-Error wrong-type-argument (logand 3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (dolist (three '(3 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
473 (Assert (eq 3 (logand three)) three)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
474 (Assert (eq 3 (logxor three)) three)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
475 (Assert (eq 3 (logior three)) three)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
476 (Assert (eq 3 (logand three three)) three)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
477 (Assert (eq 0 (logxor three three)) three)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
478 (Assert (eq 3 (logior three three))) three)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (dolist (one `(1 ?\01 ,(Int-to-Marker 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (dolist (two '(2 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
482 (Assert (eq 0 (logand one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
483 (Assert (eq 3 (logior one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
484 (Assert (eq 3 (logxor one two)) (list one two)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (dolist (three '(3 ?\03))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
486 (Assert (eq 1 (logand one three)) (list one three))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
487 (Assert (eq 3 (logior one three)) (list one three))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
488 (Assert (eq 2 (logxor one three)) (list one three))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 ;; Test `%', mod
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (Check-Error wrong-number-of-arguments (%))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (Check-Error wrong-number-of-arguments (% 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (Check-Error wrong-number-of-arguments (% 1 2 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (Check-Error wrong-number-of-arguments (mod))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (Check-Error wrong-number-of-arguments (mod 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (Check-Error wrong-number-of-arguments (mod 1 2 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (Check-Error wrong-type-argument (% 10.0 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (Check-Error wrong-type-argument (% 10 2.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
504 (flet ((test1 (x) (Assert (eql x (+ (% x 17) (* (/ x 17) 17))) x))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
505 (test2 (x) (Assert (eql (- x) (+ (% (- x) 17) (* (/ (- x) 17) 17))) x))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
506 (test3 (x) (Assert (eql x (+ (% (- x) 17) (* (/ (- x) 17) 17))) x))
2075
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
507 (test4 (x) (Assert (eql (% x -17) (- (% (- x) 17))) x))
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
508 (test5 (x) (Assert (eql (% x -17) (% (- x) 17))) x))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
509 (test1 most-negative-fixnum)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
510 (if (featurep 'bignum)
2075
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
511 (progn
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
512 (test2 most-negative-fixnum)
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
513 (test4 most-negative-fixnum))
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
514 (test3 most-negative-fixnum)
c0dad8c0e80d [xemacs-hg @ 2004-05-13 15:33:15 by james]
james
parents: 2056
diff changeset
515 (test5 most-negative-fixnum))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
516 (test1 most-positive-fixnum)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
517 (test2 most-positive-fixnum)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
518 (test4 most-positive-fixnum)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
519 (dotimes (j 30)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
520 (let ((x (random)))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
521 (if (eq x most-negative-fixnum) (setq x (1+ x)))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
522 (if (eq x most-positive-fixnum) (setq x (1- x)))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
523 (test1 x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
524 (test2 x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
525 (test4 x))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (macrolet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 ((division-test (seven)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 `(progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 (Assert (eq (% ,seven 2) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 (Assert (eq (% ,seven -2) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 (Assert (eq (% (- ,seven) 2) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 (Assert (eq (% (- ,seven) -2) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 (Assert (eq (% ,seven 4) 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 (Assert (eq (% ,seven -4) 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 (Assert (eq (% (- ,seven) 4) -3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 (Assert (eq (% (- ,seven) -4) -3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 (Assert (eq (% 35 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 (Assert (eq (% -35 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 (Assert (eq (% 35 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 (Assert (eq (% -35 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 (Assert (eq (mod ,seven 2) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 (Assert (eq (mod ,seven -2) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 (Assert (eq (mod (- ,seven) 2) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 (Assert (eq (mod (- ,seven) -2) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 (Assert (eq (mod ,seven 4) 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (Assert (eq (mod ,seven -4) -1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (Assert (eq (mod (- ,seven) 4) 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (Assert (eq (mod (- ,seven) -4) -3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (Assert (eq (mod 35 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 (Assert (eq (mod -35 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (Assert (eq (mod 35 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 (Assert (eq (mod -35 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (Assert (= (mod ,seven 2.0) 1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 (Assert (= (mod ,seven -2.0) -1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 (Assert (= (mod (- ,seven) 2.0) 1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 (Assert (= (mod (- ,seven) -2.0) -1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (Assert (= (mod ,seven 4.0) 3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 (Assert (= (mod ,seven -4.0) -1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 (Assert (= (mod (- ,seven) 4.0) 1.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 (Assert (= (mod (- ,seven) -4.0) -3.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 (Assert (eq (% 0 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (Assert (eq (% 0 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 (Assert (eq (mod 0 ,seven) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 (Assert (eq (mod 0 (- ,seven)) 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (Assert (= (mod 0.0 ,seven) 0.0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (Assert (= (mod 0.0 (- ,seven)) 0.0)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 (division-test 7)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 (division-test ?\07)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 (division-test (Int-to-Marker 7)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
583 (when (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
584 (let ((big (+ (* 7 most-positive-fixnum 6)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
585 (negbig (- (* 7 most-negative-fixnum 6))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
586 (= (% big (1+ most-positive-fixnum)) most-positive-fixnum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
587 (= (% negbig (1- most-negative-fixnum)) most-negative-fixnum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
588 (= (mod big (1+ most-positive-fixnum)) most-positive-fixnum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
589 (= (mod negbig (1- most-negative-fixnum)) most-negative-fixnum)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 ;; Arithmetic comparison operations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 (Check-Error wrong-number-of-arguments (=))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (Check-Error wrong-number-of-arguments (<))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 (Check-Error wrong-number-of-arguments (>))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (Check-Error wrong-number-of-arguments (<=))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 (Check-Error wrong-number-of-arguments (>=))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (Check-Error wrong-number-of-arguments (/=))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 ;; One argument always yields t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 (loop for x in `(1 1.0 ,(Int-to-Marker 1) ?z) do
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
603 (Assert (eq t (= x)) x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
604 (Assert (eq t (< x)) x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
605 (Assert (eq t (> x)) x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
606 (Assert (eq t (>= x)) x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
607 (Assert (eq t (<= x)) x)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
608 (Assert (eq t (/= x)) x)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 ;; Type checking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 (Check-Error wrong-type-argument (= 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 (Check-Error wrong-type-argument (<= 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (Check-Error wrong-type-argument (>= 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (Check-Error wrong-type-argument (< 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (Check-Error wrong-type-argument (> 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 (Check-Error wrong-type-argument (/= 'foo 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 ;; Meat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
622 (Assert (< one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
623 (Assert (<= one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
624 (Assert (<= two two) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
625 (Assert (> two one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
626 (Assert (>= two one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
627 (Assert (>= two two) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
628 (Assert (/= one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
629 (Assert (not (/= two two)) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
630 (Assert (not (< one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
631 (Assert (not (> one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
632 (Assert (<= one one two two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
633 (Assert (not (< one one two two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
634 (Assert (>= two two one one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
635 (Assert (not (> two two one one)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
636 (Assert (= one one one) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
637 (Assert (not (= one one one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
638 (Assert (not (/= one two one)) (list one two))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 (dolist (one `(1 1.0 ,(Int-to-Marker 1) ?\01))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (dolist (two '(2 2.0 ?\02))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
643 (Assert (< one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
644 (Assert (<= one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
645 (Assert (<= two two) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
646 (Assert (> two one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
647 (Assert (>= two one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
648 (Assert (>= two two) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
649 (Assert (/= one two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
650 (Assert (not (/= two two)) two)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
651 (Assert (not (< one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
652 (Assert (not (> one one)) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
653 (Assert (<= one one two two) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
654 (Assert (not (< one one two two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
655 (Assert (>= two two one one) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
656 (Assert (not (> two two one one)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
657 (Assert (= one one one) one)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
658 (Assert (not (= one one one two)) (list one two))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
659 (Assert (not (/= one two one)) (list one two))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 ;; ad-hoc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 (Assert (< 1 2))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (Assert (< 1 2 3 4 5 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 (Assert (not (< 1 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 (Assert (not (< 2 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (Assert (not (< 1 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 (Assert (< 1 2 3 4 5 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (Assert (<= 1 2 3 4 5 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (Assert (<= 1 2 3 4 5 6 6))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (Assert (not (< 1 2 3 4 5 6 6)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 (Assert (<= 1 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (Assert (not (eq (point) (point-marker))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (Assert (= 1 (Int-to-Marker 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 (Assert (= (point) (point-marker)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
680 (when (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
681 (let ((big1 (1+ most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
682 (big2 (* 10 most-positive-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
683 (small1 (1- most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
684 (small2 (* 10 most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
685 (Assert (< small2 small1 most-negative-fixnum most-positive-fixnum big1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
686 big2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
687 (Assert (<= small2 small1 most-negative-fixnum most-positive-fixnum big1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
688 big2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
689 (Assert (> big2 big1 most-positive-fixnum most-negative-fixnum small1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
690 small2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
691 (Assert (>= big2 big1 most-positive-fixnum most-negative-fixnum small1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
692 small2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
693 (Assert (/= small2 small1 most-negative-fixnum most-positive-fixnum big1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
694 big2))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
695
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
696 (when (featurep 'ratio)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
697 (let ((big1 (div (* 10 most-positive-fixnum) 4))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
698 (big2 (div (* 5 most-positive-fixnum) 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
699 (big3 (div (* 7 most-positive-fixnum) 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
700 (small1 (div (* 10 most-negative-fixnum) 4))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
701 (small2 (div (* 5 most-negative-fixnum) 2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
702 (small3 (div (* 7 most-negative-fixnum) 2)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
703 (Assert (= big1 big2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
704 (Assert (= small1 small2))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
705 (Assert (< small3 small1 most-negative-fixnum most-positive-fixnum big1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
706 big3))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
707 (Assert (<= small3 small2 small1 most-negative-fixnum most-positive-fixnum
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
708 big1 big2 big3))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
709 (Assert (> big3 big1 most-positive-fixnum most-negative-fixnum small1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
710 small3))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
711 (Assert (>= big3 big2 big1 most-positive-fixnum most-negative-fixnum
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
712 small1 small2 small3))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
713 (Assert (/= big3 big1 most-positive-fixnum most-negative-fixnum small1
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
714 small3))))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
715
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 ;; testing list-walker functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 (macrolet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 ((test-fun
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 (fun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 `(progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 (Check-Error wrong-number-of-arguments (,fun))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 (Check-Error wrong-number-of-arguments (,fun nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (Check-Error malformed-list (,fun nil 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 ,@(loop for n in '(1 2 2000)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 collect `(Check-Error circular-list (,fun 1 (make-circular-list ,n))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 (test-funs (&rest funs) `(progn ,@(loop for fun in funs collect `(test-fun ,fun)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 (test-funs member old-member
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 memq old-memq
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 assoc old-assoc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 rassoc old-rassoc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 rassq old-rassq
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 delete old-delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 delq old-delq
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 remassoc remassq remrassoc remrassq))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 (let ((x '((1 . 2) 3 (4 . 5))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 (Assert (eq (assoc 1 x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 (Assert (eq (assq 1 x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 (Assert (eq (rassoc 1 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 (Assert (eq (rassq 1 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 (Assert (eq (assoc 2 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 (Assert (eq (assq 2 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 (Assert (eq (rassoc 2 x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 (Assert (eq (rassq 2 x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 (Assert (eq (assoc 3 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 (Assert (eq (assq 3 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 (Assert (eq (rassoc 3 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 (Assert (eq (rassq 3 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 (Assert (eq (assoc 4 x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (Assert (eq (assq 4 x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 (Assert (eq (rassoc 4 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 (Assert (eq (rassq 4 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 (Assert (eq (assoc 5 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 (Assert (eq (assq 5 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 (Assert (eq (rassoc 5 x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 (Assert (eq (rassq 5 x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 (Assert (eq (assoc 6 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 (Assert (eq (assq 6 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 (Assert (eq (rassoc 6 x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 (Assert (eq (rassq 6 x) nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 (let ((x '(("1" . "2") "3" ("4" . "5"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 (Assert (eq (assoc "1" x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 (Assert (eq (assq "1" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 (Assert (eq (rassoc "1" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 (Assert (eq (rassq "1" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 (Assert (eq (assoc "2" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 (Assert (eq (assq "2" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 (Assert (eq (rassoc "2" x) (car x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 (Assert (eq (rassq "2" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 (Assert (eq (assoc "3" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 (Assert (eq (assq "3" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 (Assert (eq (rassoc "3" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 (Assert (eq (rassq "3" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 (Assert (eq (assoc "4" x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 (Assert (eq (assq "4" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 (Assert (eq (rassoc "4" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 (Assert (eq (rassq "4" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 (Assert (eq (assoc "5" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 (Assert (eq (assq "5" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 (Assert (eq (rassoc "5" x) (caddr x)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 (Assert (eq (rassq "5" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 (Assert (eq (assoc "6" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 (Assert (eq (assq "6" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 (Assert (eq (rassoc "6" x) nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (Assert (eq (rassq "6" x) nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 (flet ((a () (list '(1 . 2) 3 '(4 . 5))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 (Assert (let* ((x (a)) (y (remassoc 1 x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 (Assert (let* ((x (a)) (y (remassq 1 x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 (Assert (let* ((x (a)) (y (remrassoc 1 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 (Assert (let* ((x (a)) (y (remrassq 1 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 (Assert (let* ((x (a)) (y (remassoc 2 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 (Assert (let* ((x (a)) (y (remassq 2 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 (Assert (let* ((x (a)) (y (remrassoc 2 x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 (Assert (let* ((x (a)) (y (remrassq 2 x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 (Assert (let* ((x (a)) (y (remassoc 3 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 (Assert (let* ((x (a)) (y (remassq 3 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 (Assert (let* ((x (a)) (y (remrassoc 3 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 (Assert (let* ((x (a)) (y (remrassq 3 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 (Assert (let* ((x (a)) (y (remassoc 4 x))) (and (eq x y) (equal y '((1 . 2) 3)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 (Assert (let* ((x (a)) (y (remassq 4 x))) (and (eq x y) (equal y '((1 . 2) 3)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 (Assert (let* ((x (a)) (y (remrassoc 4 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 (Assert (let* ((x (a)) (y (remrassq 4 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 (Assert (let* ((x (a)) (y (remassoc 5 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 (Assert (let* ((x (a)) (y (remassq 5 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 (Assert (let* ((x (a)) (y (remrassoc 5 x))) (and (eq x y) (equal y '((1 . 2) 3)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 (Assert (let* ((x (a)) (y (remrassq 5 x))) (and (eq x y) (equal y '((1 . 2) 3)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 (Assert (let* ((x (a)) (y (remassoc 6 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 (Assert (let* ((x (a)) (y (remassq 6 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 (Assert (let* ((x (a)) (y (remrassoc 6 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 (Assert (let* ((x (a)) (y (remrassq 6 x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 (Assert (let* ((x (a)) (y (delete 3 x))) (and (eq x y) (equal y '((1 . 2) (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 (Assert (let* ((x (a)) (y (delq 3 x))) (and (eq x y) (equal y '((1 . 2) (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 (Assert (let* ((x (a)) (y (old-delete 3 x))) (and (eq x y) (equal y '((1 . 2) (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 (Assert (let* ((x (a)) (y (old-delq 3 x))) (and (eq x y) (equal y '((1 . 2) (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 (Assert (let* ((x (a)) (y (delete '(1 . 2) x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 (Assert (let* ((x (a)) (y (delq '(1 . 2) x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 (Assert (let* ((x (a)) (y (old-delete '(1 . 2) x))) (and (not (eq x y)) (equal y '(3 (4 . 5))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 (Assert (let* ((x (a)) (y (old-delq '(1 . 2) x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 (flet ((a () (list '("1" . "2") "3" '("4" . "5"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 (Assert (let* ((x (a)) (y (remassoc "1" x))) (and (not (eq x y)) (equal y '("3" ("4" . "5"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 (Assert (let* ((x (a)) (y (remassq "1" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 (Assert (let* ((x (a)) (y (remrassoc "1" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 (Assert (let* ((x (a)) (y (remrassq "1" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 (Assert (let* ((x (a)) (y (remassoc "2" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 (Assert (let* ((x (a)) (y (remassq "2" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 (Assert (let* ((x (a)) (y (remrassoc "2" x))) (and (not (eq x y)) (equal y '("3" ("4" . "5"))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 (Assert (let* ((x (a)) (y (remrassq "2" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 (Assert (let* ((x (a)) (y (remassoc "3" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 (Assert (let* ((x (a)) (y (remassq "3" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 (Assert (let* ((x (a)) (y (remrassoc "3" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 (Assert (let* ((x (a)) (y (remrassq "3" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 (Assert (let* ((x (a)) (y (remassoc "4" x))) (and (eq x y) (equal y '(("1" . "2") "3")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 (Assert (let* ((x (a)) (y (remassq "4" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 (Assert (let* ((x (a)) (y (remrassoc "4" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 (Assert (let* ((x (a)) (y (remrassq "4" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 (Assert (let* ((x (a)) (y (remassoc "5" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 (Assert (let* ((x (a)) (y (remassq "5" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 (Assert (let* ((x (a)) (y (remrassoc "5" x))) (and (eq x y) (equal y '(("1" . "2") "3")))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 (Assert (let* ((x (a)) (y (remrassq "5" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 (Assert (let* ((x (a)) (y (remassoc "6" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 (Assert (let* ((x (a)) (y (remassq "6" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 (Assert (let* ((x (a)) (y (remrassoc "6" x))) (and (eq x y) (equal y (a)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 (Assert (let* ((x (a)) (y (remrassq "6" x))) (and (eq x y) (equal y (a))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 ;; function-max-args, function-min-args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 (defmacro check-function-argcounts (fun min max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 `(progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 (Assert (eq (function-min-args ,fun) ,min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 (Assert (eq (function-max-args ,fun) ,max))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 (check-function-argcounts 'prog1 1 nil) ; special form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 (check-function-argcounts 'command-execute 1 3) ; normal subr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 (check-function-argcounts 'funcall 1 nil) ; `MANY' subr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 (check-function-argcounts 'garbage-collect 0 0) ; no args subr
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 ;; Test interpreted and compiled functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 (loop for (arglist min max) in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 '(((arg1 arg2 &rest args) 2 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 ((arg1 arg2 &optional arg3 arg4) 2 4)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 ((arg1 arg2 &optional arg3 arg4 &rest args) 2 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 (() 0 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 (eval
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 `(progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 (defun test-fun ,arglist nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 (check-function-argcounts '(lambda ,arglist nil) ,min ,max)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 (check-function-argcounts (byte-compile '(lambda ,arglist nil)) ,min ,max))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 ;; Detection of cyclic variable indirection loops
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 (fset 'test-sym1 'test-sym1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 (Check-Error cyclic-function-indirection (test-sym1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 (fset 'test-sym1 'test-sym2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 (fset 'test-sym2 'test-sym1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 (Check-Error cyclic-function-indirection (test-sym1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 (fmakunbound 'test-sym1) ; else macroexpand-internal infloops!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 (fmakunbound 'test-sym2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 ;; Test `type-of'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 (Assert (eq (type-of load-path) 'cons))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 (Assert (eq (type-of obarray) 'vector))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 (Assert (eq (type-of 42) 'integer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 (Assert (eq (type-of ?z) 'character))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 (Assert (eq (type-of "42") 'string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 (Assert (eq (type-of 'foo) 'symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 (Assert (eq (type-of (selected-device)) 'device))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 ;; Test mapping functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 (Check-Error wrong-type-argument (mapcar #'identity (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 (Assert (equal (mapcar #'identity load-path) load-path))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 (Assert (equal (mapcar #'identity '(1 2 3)) '(1 2 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 (Assert (equal (mapcar #'identity "123") '(?1 ?2 ?3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 (Assert (equal (mapcar #'identity [1 2 3]) '(1 2 3)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 (Assert (equal (mapcar #'identity #*010) '(0 1 0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 (let ((z 0) (list (make-list 1000 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 (mapc (lambda (x) (incf z x)) list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 (Assert (eq 1000 z)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 (Check-Error wrong-type-argument (mapvector #'identity (current-buffer)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 (Assert (equal (mapvector #'identity '(1 2 3)) [1 2 3]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 (Assert (equal (mapvector #'identity "123") [?1 ?2 ?3]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 (Assert (equal (mapvector #'identity [1 2 3]) [1 2 3]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 (Assert (equal (mapvector #'identity #*010) [0 1 0]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 (Check-Error wrong-type-argument (mapconcat #'identity (current-buffer) "foo"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 (Assert (equal (mapconcat #'identity '("1" "2" "3") "|") "1|2|3"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 (Assert (equal (mapconcat #'identity ["1" "2" "3"] "|") "1|2|3"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
939 ;; The following 2 functions used to crash XEmacs via mapcar1().
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
940 ;; We don't test the actual values of the mapcar, since they're undefined.
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
941 (Assert
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
942 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3))))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
943 (mapcar
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
944 (lambda (y)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
945 "Devious evil mapping function"
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
946 (when (eq (car y) 2) ; go out onto a limb
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
947 (setcdr x nil) ; cut it off behind us
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
948 (garbage-collect)) ; are we riding a magic broomstick?
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
949 (car y)) ; sorry, hard landing
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
950 x)))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
951
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
952 (Assert
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
953 (let ((x (list (cons 1 1) (cons 2 2) (cons 3 3))))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
954 (mapcar
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
955 (lambda (y)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
956 "Devious evil mapping function"
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
957 (when (eq (car y) 1)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
958 (setcdr (cdr x) 42)) ; drop a brick wall onto the freeway
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
959 (car y))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
960 x)))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
961
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 ;; Test vector functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 (Assert (equal [1 2 3] [1 2 3]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 (Assert (equal [] []))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 (Assert (not (equal [1 2 3] [])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 (Assert (not (equal [1 2 3] [1 2 4])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 (Assert (not (equal [0 2 3] [1 2 3])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 (Assert (not (equal [1 2 3] [1 2 3 4])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 (Assert (not (equal [1 2 3 4] [1 2 3])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 (Assert (equal (vector 1 2 3) [1 2 3]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 (Assert (equal (make-vector 3 1) [1 1 1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 ;; Test bit-vector functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 (Assert (equal #*010 #*010))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 (Assert (equal #* #*))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 (Assert (not (equal #*010 #*011)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 (Assert (not (equal #*010 #*)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 (Assert (not (equal #*110 #*010)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 (Assert (not (equal #*010 #*0100)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 (Assert (not (equal #*0101 #*010)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 (Assert (equal (bit-vector 0 1 0) #*010))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 (Assert (equal (make-bit-vector 3 1) #*111))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 (Assert (equal (make-bit-vector 3 0) #*000))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 ;; Test buffer-local variables used as (ugh!) function parameters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 (make-local-variable 'test-emacs-buffer-local-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 (byte-compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 (defun test-emacs-buffer-local-parameter (test-emacs-buffer-local-variable)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 (setq test-emacs-buffer-local-variable nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 (test-emacs-buffer-local-parameter nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 ;;-----------------------------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 ;; Test split-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 ;;-----------------------------------------------------
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1001 ;; Keep nulls, explicit SEPARATORS
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1002 ;; Hrvoje didn't like the next 3 tests so I'm disabling them for now. -sb
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1003 ;; I assume Hrvoje worried about the possibility of infloops. -sjt
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1004 (when test-harness-risk-infloops
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1005 (Assert (equal (split-string "foo" "") '("" "f" "o" "o" "")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1006 (Assert (equal (split-string "foo" "^") '("" "foo")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1007 (Assert (equal (split-string "foo" "$") '("foo" ""))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 (Assert (equal (split-string "foo,bar" ",") '("foo" "bar")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 (Assert (equal (split-string ",foo,bar," ",") '("" "foo" "bar" "")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 (Assert (equal (split-string ",foo,bar," "^,") '("" "foo,bar,")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 (Assert (equal (split-string ",foo,bar," ",$") '(",foo,bar" "")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 (Assert (equal (split-string ",foo,,bar," ",") '("" "foo" "" "bar" "")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 (Assert (equal (split-string "foo,,,bar" ",") '("foo" "" "" "bar")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 (Assert (equal (split-string "foo,,bar,," ",") '("foo" "" "bar" "" "")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 (Assert (equal (split-string "foo,,bar" ",+") '("foo" "bar")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 (Assert (equal (split-string ",foo,,bar," ",+") '("" "foo" "bar" "")))
1425
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1017 ;; Omit nulls, explicit SEPARATORS
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1018 (when test-harness-risk-infloops
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1019 (Assert (equal (split-string "foo" "" t) '("f" "o" "o")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1020 (Assert (equal (split-string "foo" "^" t) '("foo")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1021 (Assert (equal (split-string "foo" "$" t) '("foo"))))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1022 (Assert (equal (split-string "foo,bar" "," t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1023 (Assert (equal (split-string ",foo,bar," "," t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1024 (Assert (equal (split-string ",foo,bar," "^," t) '("foo,bar,")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1025 (Assert (equal (split-string ",foo,bar," ",$" t) '(",foo,bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1026 (Assert (equal (split-string ",foo,,bar," "," t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1027 (Assert (equal (split-string "foo,,,bar" "," t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1028 (Assert (equal (split-string "foo,,bar,," "," t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1029 (Assert (equal (split-string "foo,,bar" ",+" t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1030 (Assert (equal (split-string ",foo,,bar," ",+" t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1031 ;; "Double-default" case
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1032 (Assert (equal (split-string "foo bar") '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1033 (Assert (equal (split-string " foo bar ") '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1034 (Assert (equal (split-string " foo bar ") '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1035 (Assert (equal (split-string "foo bar") '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1036 (Assert (equal (split-string "foo bar ") '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1037 (Assert (equal (split-string "foobar") '("foobar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1038 ;; Semantics are identical to "double-default" case! Fool ya?
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1039 (Assert (equal (split-string "foo bar" nil t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1040 (Assert (equal (split-string " foo bar " nil t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1041 (Assert (equal (split-string " foo bar " nil t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1042 (Assert (equal (split-string "foo bar" nil t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1043 (Assert (equal (split-string "foo bar " nil t) '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1044 (Assert (equal (split-string "foobar" nil t) '("foobar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1045 ;; Perverse "anti-double-default" case
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1046 (Assert (equal (split-string "foo bar" split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1047 '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1048 (Assert (equal (split-string " foo bar " split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1049 '("" "foo" "bar" "")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1050 (Assert (equal (split-string " foo bar " split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1051 '("" "foo" "bar" "")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1052 (Assert (equal (split-string "foo bar" split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1053 '("foo" "bar")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1054 (Assert (equal (split-string "foo bar " split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1055 '("foo" "bar" "")))
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1056 (Assert (equal (split-string "foobar" split-string-default-separators)
74cb069b8417 [xemacs-hg @ 2003-04-23 15:42:44 by stephent]
stephent
parents: 826
diff changeset
1057 '("foobar")))
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1058
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1059 (Assert (not (string-match "\\(\\.\\=\\)" ".")))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1060 (Assert (string= "" (let ((str "test string"))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1061 (if (string-match "^.*$" str)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1062 (replace-match "\\U" t nil str)))))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1063 (with-temp-buffer
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1064 (erase-buffer)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1065 (insert "test string")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1066 (re-search-backward "^.*$")
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1067 (replace-match "\\U" t)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1068 (Assert (and (bobp) (eobp))))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1069
434
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1070 ;;-----------------------------------------------------
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1071 ;; Test near-text buffer functions.
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1072 ;;-----------------------------------------------------
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1073 (with-temp-buffer
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1074 (erase-buffer)
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1075 (Assert (eq (char-before) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1076 (Assert (eq (char-before (point)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1077 (Assert (eq (char-before (point-marker)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1078 (Assert (eq (char-before (point) (current-buffer)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1079 (Assert (eq (char-before (point-marker) (current-buffer)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1080 (Assert (eq (char-after) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1081 (Assert (eq (char-after (point)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1082 (Assert (eq (char-after (point-marker)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1083 (Assert (eq (char-after (point) (current-buffer)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1084 (Assert (eq (char-after (point-marker) (current-buffer)) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1085 (Assert (eq (preceding-char) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1086 (Assert (eq (preceding-char (current-buffer)) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1087 (Assert (eq (following-char) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1088 (Assert (eq (following-char (current-buffer)) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1089 (insert "foobar")
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1090 (Assert (eq (char-before) ?r))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1091 (Assert (eq (char-after) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1092 (Assert (eq (preceding-char) ?r))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1093 (Assert (eq (following-char) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1094 (goto-char (point-min))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1095 (Assert (eq (char-before) nil))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1096 (Assert (eq (char-after) ?f))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1097 (Assert (eq (preceding-char) 0))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1098 (Assert (eq (following-char) ?f))
9d177e8d4150 Import from CVS: tag r21-2-25
cvs
parents: 428
diff changeset
1099 )
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1100
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1101 ;;-----------------------------------------------------
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1102 ;; Test plist manipulation functions.
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1103 ;;-----------------------------------------------------
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1104 (let ((sym (make-symbol "test-symbol")))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1105 (Assert (eq t (get* sym t t)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1106 (Assert (eq t (get sym t t)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1107 (Assert (eq t (getf nil t t)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1108 (Assert (eq t (plist-get nil t t)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1109 (put sym 'bar 'baz)
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1110 (Assert (eq 'baz (get sym 'bar)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1111 (Assert (eq 'baz (getf '(bar baz) 'bar)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1112 (Assert (eq 'baz (getf (symbol-plist sym) 'bar)))
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1113 (Assert (eq 2 (getf '(1 2) 1)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1114 (Assert (eq 4 (put sym 3 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1115 (Assert (eq 4 (get sym 3)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1116 (Assert (eq t (remprop sym 3)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1117 (Assert (eq nil (remprop sym 3)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1118 (Assert (eq 5 (get sym 3 5)))
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 434
diff changeset
1119 )
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1120
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1121 (loop for obj in
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1122 (list (make-symbol "test-symbol")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1123 "test-string"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1124 (make-extent nil nil nil)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1125 (make-face 'test-face))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1126 do
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1127 (Assert (eq 2 (get obj ?1 2)) obj)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1128 (Assert (eq 4 (put obj ?3 4)) obj)
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1129 (Assert (eq 4 (get obj ?3)) obj)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1130 (when (or (stringp obj) (symbolp obj))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1131 (Assert (equal '(?3 4) (object-plist obj)) obj))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1132 (Assert (eq t (remprop obj ?3)) obj)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1133 (when (or (stringp obj) (symbolp obj))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1134 (Assert (eq '() (object-plist obj)) obj))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1135 (Assert (eq nil (remprop obj ?3)) obj)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1136 (when (or (stringp obj) (symbolp obj))
2056
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1137 (Assert (eq '() (object-plist obj)) obj))
ab71063baf27 [xemacs-hg @ 2004-05-03 15:08:41 by james]
james
parents: 1983
diff changeset
1138 (Assert (eq 5 (get obj ?3 5)) obj)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1139 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1140
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1141 (Check-Error-Message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1142 error "Object type has no properties"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1143 (get 2 'property))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1144
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1145 (Check-Error-Message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1146 error "Object type has no settable properties"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1147 (put (current-buffer) 'property 'value))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1148
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1149 (Check-Error-Message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1150 error "Object type has no removable properties"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1151 (remprop ?3 'property))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1152
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1153 (Check-Error-Message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1154 error "Object type has no properties"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1155 (object-plist (symbol-function 'car)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1156
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1157 (Check-Error-Message
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1158 error "Can't remove property from object"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1159 (remprop (make-extent nil nil nil) 'detachable))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1160
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1161 ;;-----------------------------------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1162 ;; Test subseq
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1163 ;;-----------------------------------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1164 (Assert (equal (subseq nil 0) nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1165 (Assert (equal (subseq [1 2 3] 0) [1 2 3]))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1166 (Assert (equal (subseq [1 2 3] 1 -1) [2]))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1167 (Assert (equal (subseq "123" 0) "123"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1168 (Assert (equal (subseq "1234" -3 -1) "23"))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1169 (Assert (equal (subseq #*0011 0) #*0011))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1170 (Assert (equal (subseq #*0011 -3 3) #*01))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1171 (Assert (equal (subseq '(1 2 3) 0) '(1 2 3)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1172 (Assert (equal (subseq '(1 2 3 4) -3 nil) '(2 3 4)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1173
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1174 (Check-Error wrong-type-argument (subseq 3 2))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1175 (Check-Error args-out-of-range (subseq [1 2 3] -42))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1176 (Check-Error args-out-of-range (subseq [1 2 3] 0 42))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1177
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1178 ;;-----------------------------------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1179 ;; Time-related tests
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1180 ;;-----------------------------------------------------
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1181 (Assert (= (length (current-time-string)) 24))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1182
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1183 ;;-----------------------------------------------------
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1184 ;; format test
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1185 ;;-----------------------------------------------------
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1186 (Assert (string= (format "%d" 10) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1187 (Assert (string= (format "%o" 8) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1188 (Assert (string= (format "%x" 31) "1f"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1189 (Assert (string= (format "%X" 31) "1F"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1190 ;; MS-Windows uses +002 in its floating-point numbers. #### We should
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1191 ;; perhaps fix this, but writing our own floating-point support in doprnt.c
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1192 ;; is very hard.
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1193 (Assert (or (string= (format "%e" 100) "1.000000e+02")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1194 (string= (format "%e" 100) "1.000000e+002")))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1195 (Assert (or (string= (format "%E" 100) "1.000000E+02")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1196 (string= (format "%E" 100) "1.000000E+002")))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1197 (Assert (or (string= (format "%E" 100) "1.000000E+02")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1198 (string= (format "%E" 100) "1.000000E+002")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1199 (Assert (string= (format "%f" 100) "100.000000"))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1200 (Assert (string= (format "%7.3f" 12.12345) " 12.123"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1201 (Assert (string= (format "%07.3f" 12.12345) "012.123"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1202 (Assert (string= (format "%-7.3f" 12.12345) "12.123 "))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1203 (Assert (string= (format "%-07.3f" 12.12345) "12.123 "))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1204 (Assert (string= (format "%g" 100.0) "100"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1205 (Assert (or (string= (format "%g" 0.000001) "1e-06")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1206 (string= (format "%g" 0.000001) "1e-006")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1207 (Assert (string= (format "%g" 0.0001) "0.0001"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1208 (Assert (string= (format "%G" 100.0) "100"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1209 (Assert (or (string= (format "%G" 0.000001) "1E-06")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1210 (string= (format "%G" 0.000001) "1E-006")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1211 (Assert (string= (format "%G" 0.0001) "0.0001"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1212
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1213 (Assert (string= (format "%2$d%1$d" 10 20) "2010"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1214 (Assert (string= (format "%-d" 10) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1215 (Assert (string= (format "%-4d" 10) "10 "))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1216 (Assert (string= (format "%+d" 10) "+10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1217 (Assert (string= (format "%+d" -10) "-10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1218 (Assert (string= (format "%+4d" 10) " +10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1219 (Assert (string= (format "%+4d" -10) " -10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1220 (Assert (string= (format "% d" 10) " 10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1221 (Assert (string= (format "% d" -10) "-10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1222 (Assert (string= (format "% 4d" 10) " 10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1223 (Assert (string= (format "% 4d" -10) " -10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1224 (Assert (string= (format "%0d" 10) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1225 (Assert (string= (format "%0d" -10) "-10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1226 (Assert (string= (format "%04d" 10) "0010"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1227 (Assert (string= (format "%04d" -10) "-010"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1228 (Assert (string= (format "%*d" 4 10) " 10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1229 (Assert (string= (format "%*d" 4 -10) " -10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1230 (Assert (string= (format "%*d" -4 10) "10 "))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1231 (Assert (string= (format "%*d" -4 -10) "-10 "))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1232 (Assert (string= (format "%#d" 10) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1233 (Assert (string= (format "%#o" 8) "010"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1234 (Assert (string= (format "%#x" 16) "0x10"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1235 (Assert (or (string= (format "%#e" 100) "1.000000e+02")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1236 (string= (format "%#e" 100) "1.000000e+002")))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1237 (Assert (or (string= (format "%#E" 100) "1.000000E+02")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1238 (string= (format "%#E" 100) "1.000000E+002")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1239 (Assert (string= (format "%#f" 100) "100.000000"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1240 (Assert (string= (format "%#g" 100.0) "100.000"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1241 (Assert (or (string= (format "%#g" 0.000001) "1.00000e-06")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1242 (string= (format "%#g" 0.000001) "1.00000e-006")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1243 (Assert (string= (format "%#g" 0.0001) "0.000100000"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1244 (Assert (string= (format "%#G" 100.0) "100.000"))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1245 (Assert (or (string= (format "%#G" 0.000001) "1.00000E-06")
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 464
diff changeset
1246 (string= (format "%#G" 0.000001) "1.00000E-006")))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1247 (Assert (string= (format "%#G" 0.0001) "0.000100000"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1248 (Assert (string= (format "%.1d" 10) "10"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1249 (Assert (string= (format "%.4d" 10) "0010"))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1250 ;; Combination of `-', `+', ` ', `0', `#', `.', `*'
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1251 (Assert (string= (format "%-04d" 10) "10 "))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1252 (Assert (string= (format "%-*d" 4 10) "10 "))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1253 ;; #### Correctness of this behavior is questionable.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1254 ;; It might be better to signal error.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1255 (Assert (string= (format "%-*d" -4 10) "10 "))
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1256 ;; These behavior is not specified.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1257 ;; (format "%-+d" 10)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1258 ;; (format "%- d" 10)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1259 ;; (format "%-01d" 10)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1260 ;; (format "%-#4x" 10)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1261 ;; (format "%-.1d" 10)
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1262
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1263 (Assert (string= (format "%01.1d" 10) "10"))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1264 (Assert (string= (format "%03.1d" 10) " 10"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1265 (Assert (string= (format "%01.3d" 10) "010"))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1266 (Assert (string= (format "%1.3d" 10) "010"))
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
1267 (Assert (string= (format "%3.1d" 10) " 10"))
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1268
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1269 ;;; The following two tests used to use 1000 instead of 100,
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1270 ;;; but that merely found buffer overflow bugs in Solaris sprintf().
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1271 (Assert (= 102 (length (format "%.100f" 3.14))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1272 (Assert (= 100 (length (format "%100f" 3.14))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1273
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1274 ;;; Check for 64-bit cleanness on LP64 platforms.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1275 (Assert (= (read (format "%d" most-positive-fixnum)) most-positive-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1276 (Assert (= (read (format "%ld" most-positive-fixnum)) most-positive-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1277 (Assert (= (read (format "%u" most-positive-fixnum)) most-positive-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1278 (Assert (= (read (format "%lu" most-positive-fixnum)) most-positive-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1279 (Assert (= (read (format "%d" most-negative-fixnum)) most-negative-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1280 (Assert (= (read (format "%ld" most-negative-fixnum)) most-negative-fixnum))
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1281
4287
89e64783d068 [xemacs-hg @ 2007-11-27 13:51:03 by aidan]
aidan
parents: 2075
diff changeset
1282 ;; These used to crash.
89e64783d068 [xemacs-hg @ 2007-11-27 13:51:03 by aidan]
aidan
parents: 2075
diff changeset
1283 (Assert (eql (read (format "%f" 1.2e+302)) 1.2e+302))
89e64783d068 [xemacs-hg @ 2007-11-27 13:51:03 by aidan]
aidan
parents: 2075
diff changeset
1284 (Assert (eql (read (format "%.1000d" 1)) 1))
89e64783d068 [xemacs-hg @ 2007-11-27 13:51:03 by aidan]
aidan
parents: 2075
diff changeset
1285
446
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1286 ;;; "%u" is undocumented, and Emacs Lisp has no unsigned type.
1ccc32a20af4 Import from CVS: tag r21-2-38
cvs
parents: 444
diff changeset
1287 ;;; What to do if "%u" is used with a negative number?
1983
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1288 ;;; For non-bignum XEmacsen, the most reasonable thing seems to be to print an
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1289 ;;; un-read-able number. The printed value might be useful to a human, if not
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1290 ;;; to Emacs Lisp.
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1291 ;;; For bignum XEmacsen, we make %u with a negative value throw an error.
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1292 (if (featurep 'bignum)
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1293 (progn
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1294 (Check-Error wrong-type-argument (format "%u" most-negative-fixnum))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1295 (Check-Error wrong-type-argument (format "%u" -1)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1296 (Check-Error invalid-read-syntax (read (format "%u" most-negative-fixnum)))
9c872f33ecbe [xemacs-hg @ 2004-04-05 22:49:31 by james]
james
parents: 1425
diff changeset
1297 (Check-Error invalid-read-syntax (read (format "%u" -1))))
448
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1298
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1299 ;; Check all-completions ignore element start with space.
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1300 (Assert (not (all-completions "" '((" hidden" . "object")))))
3078fd1074e8 Import from CVS: tag r21-2-39
cvs
parents: 446
diff changeset
1301 (Assert (all-completions " " '((" hidden" . "object"))))
4394
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1302
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1303 (let* ((literal-with-uninterned
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1304 '(first-element
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1305 [#1=#:G32976 #2=#:G32974 #3=#:G32971 #4=#:G32969 alias
4396
e97f16fb2e25 Don't assume lisp-tests.el will be correctly read as UTF-8.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4394
diff changeset
1306 #s(hash-table size 256 data (969 ?\xF9 55 ?7 166 ?\xA6))
4394
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1307 #5=#:G32970 #6=#:G32972]))
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1308 (print-readably t)
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1309 (print-gensym t)
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1310 (printed-with-uninterned (prin1-to-string literal-with-uninterned))
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1311 (awkward-regexp "#1=#")
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1312 (first-match-start (string-match awkward-regexp
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1313 printed-with-uninterned)))
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1314 (Assert (null (string-match awkward-regexp printed-with-uninterned
cacc942c0d0f Avoid clearing print-gensym-alist inappropriately when printing hash tables.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4287
diff changeset
1315 (1+ first-match-start)))))