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

Line  

1  ;* Mode: Lisp * 

2  ;;;; Author: Paul Dietz 

3  ;;;; Created: Sun Apr 20 07:21:24 2003 

4  ;;;; Contains: Tests of MAPC 

5  

6  (inpackage :cltest) 

7  

8  (compileandload "consaux.lsp") 

9  

10  (deftest mapc.1 

11  (mapc #'list nil) 

12  nil) 

13  

14  (deftest mapc.2 

15  (let ((x 0)) 

16  (let ((result 

17  (mapc #'(lambda (y) (incf x y)) 

18  '(1 2 3 4)))) 

19  (list result x))) 

20  ((1 2 3 4) 10)) 

21  

22  (deftest mapc.3 

23  (let ((x 0)) 

24  (list 

25  (mapc #'(lambda (y z) (declare (ignore y z)) (incf x)) 

26  (makelist 5 :initialelement 'a) 

27  (makelist 5 )) 

28  x)) 

29  ((a a a a a) 5)) 

30  

31  (deftest mapc.4 

32  (let ((x 0)) 

33  (list 

34  (mapc #'(lambda (y z) (declare (ignore y z)) (incf x)) 

35  (makelist 5 :initialelement 'a) 

36  (makelist 10)) 

37  x)) 

38  ((a a a a a) 5)) 

39  

40  (deftest mapc.5 

41  (let ((x 0)) 

42  (list 

43  (mapc #'(lambda (y z) (declare (ignore y z)) (incf x)) 

44  (makelist 5 :initialelement 'a) 

45  (makelist 3)) 

46  x)) 

47  ((a a a a a) 3)) 

48  

49  (deftest mapc.6 

50  (let* ((x (copylist '(a b c d e f g h))) 

51  (xcopy (makescaffoldcopy x))) 

52  (setf *mapc.6var* nil) 

53  (let ((result (mapc 'mapc.6fun x))) 

54  (and (checkscaffoldcopy x xcopy) 

55  (eqt result x) 

56  *mapc.6var*))) 

57  (h g f e d c b a)) 

58  

59  (deftest mapc.order.1 

60  (let ((i 0) x y z) 

61  (values 

62  (mapc (progn (setf x (incf i)) 

63  #'list) 

64  (progn (setf y (incf i)) 

65  '(a b c)) 

66  (progn (setf z (incf i)) 

67  '(1 2 3))) 

68  i x y z)) 

69  (a b c) 3 1 2 3) 

70  

71  ;;; Error tests 

72  

73  (deftest mapc.error.1 

74  (checktypeerror #'(lambda (x) (mapc #'identity x)) #'listp) 

75  nil) 

76  

77  (deftest mapc.error.2 

78  (signalserror (mapc) programerror) 

79  t) 

80  

81  (deftest mapc.error.3 

82  (signalserror (mapc #'append) programerror) 

83  t) 

84  

85  (deftest mapc.error.4 

86  (signalserror (locally (mapc #'identity 1) t) typeerror) 

87  t) 

88  

89  (deftest mapc.error.5 

90  (signalserror (mapc #'cons '(a b c)) programerror) 

91  t) 

92  

93  (deftest mapc.error.6 

94  (signalserror (mapc #'cons '(a b c) '(1 2 3) '(4 5 6)) programerror) 

95  t) 

96  

97  (deftest mapc.error.7 

98  (signalserror (mapc #'car '(a b c)) typeerror) 

99  t) 

100  

101  (deftest mapc.error.8 

102  (signalserror (mapc #'identity (list* 1 2 3 4)) typeerror) 

103  t) 

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