source: trunk/source/tests/ansi-tests/row-major-aref.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 2.7 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Jan 22 20:16:38 2003
4;;;; Contains: Tests of ROW-MAJOR-AREF
5
6(in-package :cl-test)
7
8;;; ROW-MAJOR-AREF is also used by equalp-with-case (see rt/rt.lsp)
9
10(deftest row-major-aref.1
11  (loop for i from 0 to 5 collect (row-major-aref #(a b c d e f) i))
12  (a b c d e f))
13
14(deftest row-major-aref.2
15  (loop for i from 0 to 5 collect (row-major-aref #2a((a b c d)(e f g h)) i))
16  (a b c d e f))
17
18(deftest row-major-aref.3
19  (row-major-aref #0a100 0)
20  100)
21
22(deftest row-major-aref.4
23  (loop for i from 0 to 5 collect (row-major-aref #*011100 i))
24  (0 1 1 1 0 0))
25
26(deftest row-major-aref.5
27  (loop for i from 0 to 5 collect (row-major-aref "abcdef" i))
28  (#\a #\b #\c #\d #\e #\f))
29
30(deftest row-major-aref.6
31  (let ((a (make-array nil :initial-element 'x)))
32    (values
33     (aref a)
34     (setf (row-major-aref a 0) 'y)
35     (aref a)
36     a))
37  x y y #0ay)
38
39(deftest row-major-aref.7
40  (let ((a (make-array '(4) :initial-element 'x)))
41    (values
42     (aref a 0)
43     (aref a 1)
44     (aref a 2)
45     (aref a 3)
46     (setf (row-major-aref a 0) 'a)
47     (setf (row-major-aref a 1) 'b)
48     (setf (row-major-aref a 2) 'c)
49     a))
50  x x x x a b c #(a b c x))
51
52(deftest row-major-aref.8
53  (let ((a (make-array '(4) :element-type 'base-char
54                       :initial-element #\x)))
55    (values
56     (aref a 0)
57     (aref a 1)
58     (aref a 2)
59     (aref a 3)
60     (setf (row-major-aref a 0) #\a)
61     (setf (row-major-aref a 1) #\b)
62     (setf (row-major-aref a 2) #\c)
63     a))
64  #\x #\x #\x #\x #\a #\b #\c "abcx")
65
66(deftest row-major-aref.9
67  (let ((a (make-array '(4) :initial-element 0
68                       :element-type 'bit)))
69    (values
70     (aref a 0)
71     (aref a 1)
72     (aref a 2)
73     (aref a 3)
74     (setf (row-major-aref a 0) 1)
75     (setf (row-major-aref a 1) 1)
76     (setf (row-major-aref a 3) 1)
77     a))
78  0 0 0 0 1 1 1 #*1101)
79
80(deftest row-major-aref.10
81  (let ((a (make-array '(2 3 4)
82                       :initial-contents '(((a b c d)(e f g h)(i j k l))
83                                           ((m n o p)(q r s t)(u v w x))))))
84    (loop for i from 0 to 23 collect (row-major-aref a i)))
85  (a b c d e f g h i j k l m n o p q r s t u v w x))
86
87(deftest row-major-aref.order.1
88  (let ((i 0) x y)
89    (values
90     (row-major-aref
91      (progn (setf x (incf i)) #(a b c d e f))
92      (progn (setf y (incf i)) 2))
93     i x y))
94  c 2 1 2)
95
96(deftest row-major-aref.order.2
97  (let ((i 0) x y z
98        (a (copy-seq #(a b c d e f))))
99    (values
100     (setf
101      (row-major-aref
102       (progn (setf x (incf i)) a)
103       (progn (setf y (incf i)) 2))
104      (progn (setf z (incf i)) 'w))
105     a i x y z))
106  w #(a b w d e f) 3 1 2 3)
107
108;;; Error tests
109
110(deftest row-major-aref.error.1
111  (signals-error (row-major-aref) program-error)
112  t)
Note: See TracBrowser for help on using the repository browser.