-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patharray-dimensions.lsp
69 lines (53 loc) · 1.53 KB
/
array-dimensions.lsp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
;-*- 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)
(deftest array-dimensions.8
(macrolet ((%m (z) z)) (array-dimensions
(expand-in-current-env (%m #2a((a b)(c d)(e f))))))
(3 2))
;;; Error tests
(deftest array-dimensions.error.1
(signals-error (array-dimensions) program-error)
t)
(deftest array-dimensions.error.2
(signals-error (array-dimensions #(a b c) nil)
program-error)
t)
(deftest array-dimensions.error.3
(check-type-error #'array-dimensions #'arrayp)
nil)
(deftest array-dimensions.error.4
(signals-type-error x nil (array-dimensions x))
t)
(deftest array-dimensions.error.5
(signals-error (locally (array-dimensions nil))
type-error)
t)