source: trunk/source/tests/ansi-tests/logorc1.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Sep  9 06:23:43 2003
4;;;; Contains: Tests of LOGORC1
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9
10;;; Error tests
11
12(deftest logorc1.error.1
13  (check-type-error #'(lambda (x) (logorc1 x 0)) #'integerp)
14  nil)
15
16(deftest logorc1.error.2
17  (check-type-error #'(lambda (x) (logorc1 0 x)) #'integerp)
18  nil)
19
20(deftest logorc1.error.3
21  (signals-error (logorc1) program-error)
22  t)
23
24(deftest logorc1.error.4
25  (signals-error (logorc1 0) program-error)
26  t)
27
28(deftest logorc1.error.5
29  (signals-error (logorc1 1 2 3) program-error)
30  t)
31
32;;; Non-error tests
33
34(deftest logorc1.1
35  (logorc1 0 0)
36  -1)
37
38(deftest logorc1.2
39  (logorc1 0 -1)
40  -1)
41
42(deftest logorc1.2a
43  (logorc1 -1 0)
44  0)
45
46(deftest logorc1.3
47  (logorc1 123 0)
48  -124)
49
50(deftest logorc1.4
51  (loop for x in *integers*
52        always (and (eql -1 (logorc1 0 x))
53                    (eql x (logorc1 -1 x))
54                    (eql -1 (logorc1 x x))
55                    (eql x (logorc1 (lognot x) x))
56                    (eql (lognot x) (logorc1 x (lognot x)))))
57  t)
58
59(deftest logorc1.5
60  (loop for x = (random-fixnum)
61        for xc = (lognot x)
62        repeat 1000
63        unless (eql x (logorc1 xc x))
64        collect x)
65  nil)
66
67(deftest logorc1.6
68  (loop for x = (random-from-interval (ash 1 (random 200)))
69        for y = (random-from-interval (ash 1 (random 200)))
70        for z = (logorc1 x y)
71        repeat 1000
72        unless (and (if (or (>= x 0) (< y 0))
73                        (< z 0)
74                      (>= z 0))
75                    (loop for i from 1 to 210
76                          always (if (or (not (logbitp i x))
77                                         (logbitp i y))
78                                     (logbitp i z)
79                                   (not (logbitp i z)))))
80        collect (list x y z))
81  nil)
82
83(deftest logorc1.order.1
84  (let ((i 0) a b)
85    (values
86     (logorc1 (progn (setf a (incf i)) -3)
87              (progn (setf b (incf i)) 17))
88     i a b))
89  19 2 1 2)
Note: See TracBrowser for help on using the repository browser.