array-total-size.lsp 1.29 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
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 21 22:01:09 2003
;;;; Contains: Tests of ARRAY-TOTAL-SIZE

(in-package :cl-test)

;;; More tests of ARRAY-TOTAL-SIZE are in make-array.lsp

(deftest array-total-size.1
  (array-total-size #0aNIL)
  1)

(deftest array-total-size.2
  (array-total-size "abcdef")
  6)

(deftest array-total-size.3
  (array-total-size #(a b c))
  3)

(deftest array-total-size.4
  (array-total-size #*0011010)
  7)

(deftest array-total-size.5
  (array-total-size #2a((1 2 3)(4 5 6)(7 8 9)(a b c)))
  12)

30 31
(deftest array-total-size.6
  (macrolet ((%m (z) z))
sds's avatar
sds committed
32
            (array-total-size (expand-in-current-env (%m #(a b c)))))
33 34
  3)

35 36 37 38 39 40 41
(deftest array-total-size.order.1
  (let ((i 0) a)
    (values
     (array-total-size (progn (setf a (incf i)) #(a b c d)))
     i a))
  4 1 1)

pfdietz's avatar
pfdietz committed
42 43 44
;;; Error tests

(deftest array-total-size.error.1
45 46
  (signals-error (array-total-size) program-error)
  t)
pfdietz's avatar
pfdietz committed
47 48

(deftest array-total-size.error.2
49 50
  (signals-error (array-total-size #(a b c) nil) program-error)
  t)
pfdietz's avatar
pfdietz committed
51 52

(deftest array-total-size.error.3
53
  (check-type-error #'array-total-size #'arrayp)
pfdietz's avatar
pfdietz committed
54 55 56
  nil)

(deftest array-total-size.error.4
57 58
  (signals-error (array-total-size 0) type-error)
  t)
59 60

(deftest array-total-size.error.5
61
  (signals-type-error x 0 (locally (array-total-size x) t))
62
  t)
63