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.9 KB

Line  

1  ;* Mode: Lisp * 

2  ;;;; Author: Paul Dietz 

3  ;;;; Created: Tue Sep 9 06:30:57 2003 

4  ;;;; Contains: Tests of LOGXOR 

5  

6  (inpackage :cltest) 

7  

8  (compileandload "numbersaux.lsp") 

9  

10  ;;; Error tests 

11  

12  (deftest logxor.error.1 

13  (checktypeerror #'logxor #'integerp) 

14  nil) 

15  

16  (deftest logxor.error.2 

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

18  nil) 

19  

20  

21  ;;; Nonerror tests 

22  

23  (deftest logxor.1 

24  (logxor) 

25  0) 

26  

27  (deftest logxor.2 

28  (logxor 1231) 

29  1231) 

30  

31  (deftest logxor.3 

32  (logxor 198) 

33  198) 

34  

35  (deftest logxor.4 

36  (loop for x in *integers* 

37  always (eql x (logxor x))) 

38  t) 

39  

40  (deftest logxor.5 

41  (loop for x in *integers* 

42  always (and (eql 1 (logxor x (lognot x))) 

43  (eql 0 (logxor x x)) 

44  (eql x (logxor x x x)))) 

45  t) 

46  

47  (deftest logxor.6 

48  (loop for x = (randomfixnum) 

49  for xc = (lognot x) 

50  repeat 1000 

51  unless (eql 1 (logxor x xc)) 

52  collect x) 

53  nil) 

54  

55  (deftest logxor.7 

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

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

58  for z = (logxor x y) 

59  repeat 1000 

60  unless (and (if (or (and (< x 0) (>= y 0)) 

61  (and (>= x 0) (< y 0))) 

62  (< z 0) 

63  (>= z 0)) 

64  (loop for i from 1 to 210 

65  always (if (or (and (logbitp i x) 

66  (not (logbitp i y))) 

67  (and (not (logbitp i x)) 

68  (logbitp i y))) 

69  (logbitp i z) 

70  (not (logbitp i z))))) 

71  collect (list x y z)) 

72  nil) 

73  

74  (deftest logxor.8 

75  (loop for i from 1 to (min 256 (1 callargumentslimit)) 

76  for args = (nconc (makelist (1 i) :initialelement 0) 

77  (list 7131)) 

78  always (eql (apply #'logxor args) 7131)) 

79  t) 

80  

81  (deftest logxor.order.1 

82  (let ((i 0) a b) 

83  (values 

84  (logxor (progn (setf a (incf i)) #b11011) 

85  (progn (setf b (incf i)) #b10110)) 

86  i a b)) 

87  #b1101 2 1 2) 

88  

89  

90  (deftest logxor.order.2 

91  (let ((i 0) a b c) 

92  (values 

93  (logxor (progn (setf a (incf i)) #b11011) 

94  (progn (setf b (incf i)) #b10110) 

95  (progn (setf c (incf i)) #b110101)) 

96  i a b c)) 

97  #b111000 3 1 2 3) 

98  

99  

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