forked from rtoy/ansi-cl-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharray-row-major-index.lsp
52 lines (41 loc) · 1.17 KB
/
array-row-major-index.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
;-*- 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
collect (array-row-major-index #(a b c d e) i))
(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
collect (array-row-major-index a i)))
(0 1 2 3 4))
(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)
(deftest array-row-major-index.order.1
(let ((x 0) y z
(a #(a b c d e f)))
(values
(array-row-major-index
(progn (setf y (incf x)) a)
(progn (setf z (incf x)) 0))
x y z))
0 2 1 2)
;;; Error tests
(deftest array-row-major-index.error.1
(signals-error (array-row-major-index) program-error)
t)