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

Rev  Line  

[8991]  1  ;* Mode: Lisp * 

 2  ;;;; Author: Paul Dietz 

 3  ;;;; Created: Tue Sep 9 06:27:45 2003 

 4  ;;;; Contains: Tests of LOGORC2 

 5  

 6  (inpackage :cltest) 

 7  

 8  (compileandload "numbersaux.lsp") 

 9  

 10  ;;; Error tests 

 11  

 12  (deftest logorc2.error.1 

 13  (checktypeerror #'(lambda (x) (logorc2 x 0)) #'integerp) 

 14  nil) 

 15  

 16  (deftest logorc2.error.2 

 17  (checktypeerror #'(lambda (x) (logorc2 0 x)) #'integerp) 

 18  nil) 

 19  

 20  (deftest logorc2.error.3 

 21  (signalserror (logorc2) programerror) 

 22  t) 

 23  

 24  (deftest logorc2.error.4 

 25  (signalserror (logorc2 0) programerror) 

 26  t) 

 27  

 28  (deftest logorc2.error.5 

 29  (signalserror (logorc2 1 2 3) programerror) 

 30  t) 

 31  

 32  ;;; Nonerror tests 

 33  

 34  (deftest logorc2.1 

 35  (logorc2 0 0) 

 36  1) 

 37  

 38  (deftest logorc2.2 

 39  (logorc2 1 0) 

 40  1) 

 41  

 42  (deftest logorc2.2a 

 43  (logorc2 0 1) 

 44  0) 

 45  

 46  (deftest logorc2.3 

 47  (logorc2 0 123) 

 48  124) 

 49  

 50  (deftest logorc2.4 

 51  (loop for x in *integers* 

 52  always (and (eql 1 (logorc2 x 0)) 

 53  (eql x (logorc2 x 1)) 

 54  (eql 1 (logorc2 x x)) 

 55  (eql x (logorc2 x (lognot x))) 

 56  (eql (lognot x) (logorc2 (lognot x) x)))) 

 57  t) 

 58  

 59  (deftest logorc2.5 

 60  (loop for x = (randomfixnum) 

 61  for xc = (lognot x) 

 62  repeat 1000 

 63  unless (eql x (logorc2 x xc)) 

 64  collect x) 

 65  nil) 

 66  

 67  (deftest logorc2.6 

 68  (loop for x = (randomfrominterval (ash 1 (random 200))) 

 69  for y = (randomfrominterval (ash 1 (random 200))) 

 70  for z = (logorc2 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 y)) 

 77  (logbitp i x)) 

 78  (logbitp i z) 

 79  (not (logbitp i z))))) 

 80  collect (list x y z)) 

 81  nil) 

 82  

 83  (deftest logorc2.order.1 

 84  (let ((i 0) a b) 

 85  (values 

 86  (logorc2 (progn (setf a (incf i)) 27) 

 87  (progn (setf b (incf i)) 1)) 

 88  i a b)) 

 89  27 2 1 2) 

 90  

Note: See
TracBrowser
for help on using the repository browser.