source: trunk/source/tests/ansi-tests/logbitp.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 07:02:00 2003
4;;;; Contains: Tests of LOGBITP
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9
10;;; Error tests
11
12(deftest logbitp.error.1
13  (signals-error (logbitp) program-error)
14  t)
15
16(deftest logbitp.error.2
17  (signals-error (logbitp 0) program-error)
18  t)
19
20(deftest logbitp.error.3
21  (signals-error (logbitp 0 0 0) program-error)
22  t)
23
24(deftest logbitp.error.4
25  (check-type-error #'(lambda (x) (logbitp x 0)) (typef 'unsigned-byte))
26  nil)
27
28(deftest logbitp.error.5
29  (check-type-error #'(lambda (x) (logbitp 0 x)) #'integerp)
30  nil)
31
32;;; Non-error tests
33
34(deftest logbitp.1
35  (loop for x in *integers*
36        unless (if (logbitp 0 x) (oddp x) (evenp x))
37        collect x)
38  nil)
39
40(deftest logbitp.2
41  (loop for len from 0 to 300
42        for i = (ash 1 len)
43        always (and (logbitp len i)
44                    (loop for j from 0 to 300
45                          always (or (eql j len)
46                                     (not (logbitp j i))))))
47  t)
48
49(deftest logbitp.3
50  (logbitp most-positive-fixnum 0)
51  nil)
52       
53(deftest logbitp.4
54  (notnot-mv (logbitp most-positive-fixnum -1))
55  t)
56
57(deftest logbitp.5
58  (logbitp (1+ most-positive-fixnum) 0)
59  nil)
60       
61(deftest logbitp.6
62  (notnot-mv (logbitp (1+ most-positive-fixnum) -1))
63  t)
64
65(deftest logbitp.7
66  (loop for len = (random 100)
67        for i = (random-from-interval (ash 1 len))
68        for k = (random (1+ len))
69        repeat 1000
70        unless (if (ldb-test (byte 1 k) i)
71                   (logbitp k i)
72                 (not (logbitp k i)))
73        collect (list i k))
74  nil)
75
76(deftest logbitp.8
77  (loop for k from 1 to 1000
78        always (logbitp k -1))
79  t)
80
81(deftest logbitp.order.1
82  (let ((i 0) a b)
83    (values
84     (logbitp (progn (setf a (incf i)) 2)
85              (progn (setf b (incf i)) #b111010))
86     i a b))
87  nil 2 1 2)
88
89
90
91
92       
93       
Note: See TracBrowser for help on using the repository browser.