array-dimensions.lsp 1.46 KB
Newer Older
pfdietz's avatar
pfdietz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 21 06:59:37 2003
;;;; Contains: Tests of ARRAY-DIMENSIONS

(in-package :cl-test)

;;; The tests in make-array.lsp also test this function

(deftest array-dimensions.1
  (array-dimensions #0aX)
  nil)

(deftest array-dimensions.2
  (array-dimensions #(a b c d))
  (4))

(deftest array-dimensions.3
  (array-dimensions #*0011011011)
  (10))

(deftest array-dimensions.4
  (array-dimensions "abcdef")
  (6))

(deftest array-dimensions.5
  (array-dimensions #2a((1 2 3)(4 5 6)(7 8 9)(10 11 12)))
  (4 3))

(deftest array-dimensions.6
  (let ((a (make-array '(2 3 4) :adjustable t)))
    (values (array-dimension a 0)
	    (array-dimension a 1)
	    (array-dimension a 2)))
  2 3 4)

(deftest array-dimensions.7
  (let ((a (make-array '(10) :fill-pointer 5)))
    (array-dimension a 0))
  10)

42
43
44
45
46
(deftest array-dimensions.8
  (macrolet ((%m (z) z)) (array-dimensions
			  (expand-in-current-env (%m #2a((a b)(c d)(e f))))))
  (3 2))

pfdietz's avatar
pfdietz committed
47
48
49
;;; Error tests

(deftest array-dimensions.error.1
50
51
  (signals-error (array-dimensions) program-error)
  t)
pfdietz's avatar
pfdietz committed
52
53

(deftest array-dimensions.error.2
54
55
56
  (signals-error (array-dimensions #(a b c) nil)
		 program-error)
  t)
pfdietz's avatar
pfdietz committed
57

pfdietz's avatar
pfdietz committed
58
(deftest array-dimensions.error.3
59
  (check-type-error #'array-dimensions #'arrayp)
pfdietz's avatar
pfdietz committed
60
  nil)
61
62

(deftest array-dimensions.error.4
63
  (signals-type-error x nil (array-dimensions x))
64
  t)
65
66

(deftest array-dimensions.error.5
67
68
69
  (signals-error (locally (array-dimensions nil))
		 type-error)
  t)