array-row-major-index.lsp 1.17 KB
Newer Older
pfdietz's avatar
pfdietz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Tue Jan 21 21:37:03 2003
;;;; Contains: Tests of ARRAY-ROW-MAJOR-INDEX

(in-package :cl-test)

;;; More array-row-major-index tests are in make-array.lsp

(deftest array-row-major-index.1
  (array-row-major-index #0aNIL)
  0)

(deftest array-row-major-index.2
  (loop for i from 0 to 4
sds's avatar
sds committed
16
        collect (array-row-major-index #(a b c d e) i))
pfdietz's avatar
pfdietz committed
17 18 19 20 21
  (0 1 2 3 4))

(deftest array-row-major-index.3
  (let ((a (make-array '(5) :fill-pointer 1)))
    (loop for i from 0 to 4
sds's avatar
sds committed
22
          collect (array-row-major-index a i)))
pfdietz's avatar
pfdietz committed
23 24
  (0 1 2 3 4))

25 26 27 28 29 30 31 32 33 34 35 36
(deftest array-row-major-index.4
  (macrolet
   ((%m (z) z))
   (array-row-major-index (expand-in-current-env (%m #(a b c))) 1))
  1)

(deftest array-row-major-index.5
  (macrolet
   ((%m (z) z))
   (array-row-major-index #(a b c) (expand-in-current-env (%m 1))))
  1)

37
(deftest array-row-major-index.order.1
38
  (let ((x 0) y z
sds's avatar
sds committed
39
        (a #(a b c d e f)))
40 41 42 43 44
    (values
     (array-row-major-index
      (progn (setf y (incf x)) a)
      (progn (setf z (incf x)) 0))
     x y z))
45
  0 2 1 2)
46

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

(deftest array-row-major-index.error.1
50 51 52
  (signals-error (array-row-major-index) program-error)
  t)