1 | ;-*- Mode: Lisp -*- |
---|

2 | ;;;; Author: Paul Dietz |
---|

3 | ;;;; Created: Tue Jan 21 06:55:14 2003 |
---|

4 | ;;;; Contains: Tests of ARRAY-DIMENSION |
---|

5 | |
---|

6 | (in-package :cl-test) |
---|

7 | |
---|

8 | ;;; array-dimension is also tested by the tests in make-array.lsp |
---|

9 | |
---|

10 | (deftest array-dimension.1 |
---|

11 | (array-dimension #(0 1 2 3) 0) |
---|

12 | 4) |
---|

13 | |
---|

14 | (deftest array-dimension.2 |
---|

15 | (array-dimension "abcdef" 0) |
---|

16 | 6) |
---|

17 | |
---|

18 | (deftest array-dimension.3 |
---|

19 | (array-dimension #2a((1 2 3 4)(5 6 7 8)) 0) |
---|

20 | 2) |
---|

21 | |
---|

22 | (deftest array-dimension.4 |
---|

23 | (array-dimension #2a((1 2 3 4)(5 6 7 8)) 1) |
---|

24 | 4) |
---|

25 | |
---|

26 | (deftest array-dimension.5 |
---|

27 | (let ((a (make-array '(10) :fill-pointer 5))) |
---|

28 | (array-dimension a 0)) |
---|

29 | 10) |
---|

30 | |
---|

31 | (deftest array-dimension.6 |
---|

32 | (let ((a (make-array '(10) :adjustable t))) |
---|

33 | (values |
---|

34 | (array-dimension a 0) |
---|

35 | (progn |
---|

36 | (adjust-array a '(20)) |
---|

37 | (array-dimension a 0)))) |
---|

38 | 10 20) |
---|

39 | |
---|

40 | (deftest array-dimension.7 |
---|

41 | (macrolet ((%m (z) z)) |
---|

42 | (array-dimension (expand-in-current-env (%m "abc")) 0)) |
---|

43 | 3) |
---|

44 | |
---|

45 | (deftest array-dimension.8 |
---|

46 | (macrolet ((%m (z) z)) |
---|

47 | (array-dimension #2a((a b)(c d)(e f)) |
---|

48 | (expand-in-current-env (%m 0)))) |
---|

49 | 3) |
---|

50 | |
---|

51 | (deftest array-dimension.order.1 |
---|

52 | (let ((i 0) a b) |
---|

53 | (values |
---|

54 | (array-dimension (progn (setf a (incf i)) #(a b c d)) |
---|

55 | (progn (setf b (incf i)) 0)) |
---|

56 | i a b)) |
---|

57 | 4 2 1 2) |
---|

58 | |
---|

59 | ;;; Error tests |
---|

60 | |
---|

61 | (deftest array-dimension.error.1 |
---|

62 | (signals-error (array-dimension) program-error) |
---|

63 | t) |
---|

64 | |
---|

65 | (deftest array-dimension.error.2 |
---|

66 | (signals-error (array-dimension #(a b c)) program-error) |
---|

67 | t) |
---|

68 | |
---|

69 | (deftest array-dimension.error.3 |
---|

70 | (signals-error (array-dimension #(a b c) 0 nil) |
---|

71 | program-error) |
---|

72 | t) |
---|