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