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

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