~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to ansi-tests/logandc2.lsp

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

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