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:
2.0 KB

Line  

1  ;* Mode: Lisp * 

2  ;;;; Author: Paul Dietz 

3  ;;;; Created: Wed Sep 3 06:51:03 2003 

4  ;;;; Contains: Tests of GCD 

5  

6  (inpackage :cltest) 

7  

8  (compileandload "numbersaux.lsp") 

9  (compileandload "gcdaux.lsp") 

10  

11  ;;; Error tests 

12  

13  (deftest gcd.error.1 

14  (checktypeerror #'gcd #'integerp) 

15  nil) 

16  

17  ;;; Nonerror tests 

18  

19  (deftest gcd.1 

20  (gcd) 

21  0) 

22  

23  (deftest gcd.2 

24  (loop for i = (randomfixnum) 

25  for a = (abs i) 

26  repeat 10000 

27  unless (and (eql a (gcd i)) 

28  (eql a (gcd 0 i))) 

29  collect i) 

30  nil) 

31  

32  (deftest gcd.3 

33  (loop for i = (randomfrominterval 10000000000000000) 

34  for a = (abs i) 

35  repeat 10000 

36  unless (and (eql a (gcd i)) 

37  (eql a (gcd i 0))) 

38  collect i) 

39  nil) 

40  

41  (deftest gcd.4 

42  (loop for i = (randomfixnum) 

43  for j = (randomfixnum) 

44  repeat 1000 

45  unless (eql (mygcd i j) (gcd i j)) 

46  collect (list i j)) 

47  nil) 

48  

49  (deftest gcd.5 

50  (let ((bound (ash 1 200))) 

51  (loop for i = (randomfrominterval bound) 

52  for j = (randomfrominterval bound) 

53  repeat 1000 

54  unless (eql (mygcd i j) (gcd i j)) 

55  collect (list i j))) 

56  nil) 

57  

58  (deftest gcd.6 

59  (loop for i = (randomfixnum) 

60  for j = (randomfixnum) 

61  for k = (randomfixnum) 

62  repeat 1000 

63  unless (eql (mygcd i (mygcd j k)) (gcd i j k)) 

64  collect (list i j k)) 

65  nil) 

66  

67  (deftest gcd.7 

68  (loop for i = (randomfixnum) 

69  for j = (randomfixnum) 

70  for k = (randomfixnum) 

71  for n = (randomfixnum) 

72  repeat 1000 

73  unless (eql (mygcd (mygcd i j) (mygcd k n)) (gcd i j k n)) 

74  collect (list i j k)) 

75  nil) 

76  

77  (deftest gcd.8 

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

79  always (eql (apply #'gcd (makelist i :initialelement 1)) 1)) 

80  t) 

81  

82  (deftest gcd.order.1 

83  (let ((i 0) x y) 

84  (values 

85  (gcd (progn (setf x (incf i)) 15) 

86  (progn (setf y (incf i)) 25)) 

87  i x y)) 

88  5 2 1 2) 

89  

90  (deftest gcd.order.2 

91  (let ((i 0) x y) 

92  (values 

93  (gcd (progn (setf x (incf i)) 0) 

94  (progn (setf y (incf i)) 10)) 

95  i x y)) 

96  10 2 1 2) 

97  

98  (deftest gcd.order.3 

99  (let ((i 0)) 

100  (values 

101  (gcd (progn (incf i) 0)) 

102  i)) 

103  0 1) 

104  

105  

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