Tagging trunk at r29452 so that the noautopack can later be synched to it.
[parrot.git] / languages / APL / t / vector.t
blobbf38c35983f581e5593152db224de9915b0d710f
1 #!perl
3 # Copyright (C) 2006-2007, The Perl Foundation.
4 # $Id$
6 use strict;
7 use warnings;
8 use lib qw(APL . lib ../lib ../../lib ../../../lib);
9 use t::APL tests => 44;
11 run_apl_is();
13 __DATA__
15 === simple vector parsing
16 --- APL: 10 2 3
17 --- out: 10 2 3
19 === simple vector parsing, with negatives.
20 --- APL: ⁻10 2 ⁻3.1
21 --- out: ⁻10 2 ⁻3.1
23 === index list
24 --- APL: ⍳5
25 --- out: 1 2 3 4 5
27 === index list, empty
28 --- APL: ⍳0
30 === index of, scalar
31 --- APL: 1 2 3 5 7 9 11⍳7
32 --- out: 5
34 === index of, scalar, not found
35 --- APL: 1 2 3 5 7 9 11⍳3.14
36 --- out: 8
38 === index of, vector
39 --- APL: 1 2 3 5 7 9 11⍳7 3 9 10
40 --- out: 5 3 6 8
42 === index of, alpha
43 --- APL: 'COKE'⍳'O'
44 --- out: 2
46 === index of, alpha, multiple
47 --- APL: 'ALPHABETICAL'⍳'CAB'
48 --- out: 10 1 6
50 === index of, not found
51 --- APL: 'AEIOU'⍳'Y'
52 --- out: 6
54 === reverse
55 --- APL: ⌽1 2 3 4 5
56 --- out: 5 4 3 2 1
58 === reverse, characters
59 --- APL: ⌽'APL IS WIERD'
60 --- out: DREIW SI LPA
62 === rotate
63 --- APL: 1⊖6 7 8 9
64 --- out: 7 8 9 6
66 === rotate multiple positions
67 --- APL: 2⊖1 2 3 4 5
68 --- out: 3 4 5 1 2
70 === rotate backwards
71 --- APL: ⁻2⊖1 2 3 4 5
72 --- out: 4 5 1 2 3
74 === rotate, but don't
75 --- APL: 0⊖1 2 3 4 5
76 --- out: 1 2 3 4 5
78 === rotate characters
79 --- APL: 3⊖'QWERTYUIOP'
80 --- out: RTYUIOPQWE
82 === rotate characters, backwards.
83 --- APL: ⁻3⊖'QWERTYUIOP'
84 --- out: IOPQWERTYU
86 === rotate characters, but don't
87 --- APL: 0⊖'QWERTYUIOP'
88 --- out: QWERTYUIOP
90 === without, characters
91 --- APL: 'APL ON PARROT'~'AEIOU '
92 --- out: PLNPRRT
94 === without, numbers
95 --- APL: 1 2 3 4 5 6 7 8 9~1 3 5 7 9
96 --- out: 2 4 6 8
98 === first
99 --- APL: ↑1 2 3 4 5
100 --- out: 1
102 === take, characters
103 --- APL: 5↑'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
104 --- out: ABCDE
106 === take, characters, negative
107 --- APL: ⁻5↑'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
108 --- out: VWXYZ
110 === take, simple vector
111 --- APL: 5↑⍳20
112 --- out: 1 2 3 4 5
114 === take, simple vector, negative
115 --- APL: ⁻5↑⍳20
116 --- out: 16 17 18 19 20
118 === drop, characters
119 --- APL: 5↓'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
120 --- out: FGHIJKLMNOPQRSTUVWXYZ
122 === drop, characters, negative
123 --- APL: ⁻5↓'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
124 --- out: ABCDEFGHIJKLMNOPQRSTU
126 === drop, simple vector
127 --- APL: 5↓⍳11
128 --- out: 6 7 8 9 10 11
130 === drop, simple vector, negative
131 --- APL: ⁻5↓⍳11
132 --- out: 1 2 3 4 5 6
134 === shape, characters
135 --- APL: ⍴'AEIOU'
136 --- out: 5
138 === shape, scalar
139 --- APL: ⍴2.3
141 === shape of shape of scalar
142 --- APL: ⍴⍴2.3
143 --- out: 0
147 === shape, vector
148 --- APL: ⍴⍳20
149 --- out: 20
151 === format, number
152 --- APL: ⍴⍕23.2
153 --- out: 4
155 === format, vector
156 --- APL: ⍴⍕⍳20
157 --- out: 50
159 === reshape, numeric vector (verify resulting shape)
160 --- APL: ⍴2 3⍴⍳6
161 --- out
162 2 3
164 === reshape, numeric vector
165 --- APL: 2 3⍴⍳6
166 --- out
167 1 2 3
168 4 5 6
170 === reshape, numeric vector, too few elements.
171 --- APL: 2 3⍴⍳2
172 --- out
173 1 2 1
174 2 1 2
176 === reshape, numeric vector, too many elements.
177 --- APL: 2 3⍴⍳10
178 --- out
179 1 2 3
180 4 5 6
182 === reshape, character vector
183 --- APL: 2 3⍴'ABCDEF'
184 --- out
188 === reshape, character vector, too few elements
189 --- APL: 2 3⍴'AB'
190 --- out
194 === reshape, character vector, too many elements
195 --- APL: 2 3⍴'ABCDEFGHIJKL'
196 --- out
200 === use reshape to create a single-element vector
201 --- todo
202 --- APL
203 ⍴1⍴2
204 --- out: 1