Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 520 lines (419 sloc) 17.259 kB
79583ce [t] moved operators/hyper.t to spec/
moritz authored
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 Hyper operators L<S03/"Hyper operators">
8
9 =end pod
10
0aedd5b [t/spec] Fudge hyper.t for Rakudo.
colomon authored
11 plan *;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
12
13 # L<S03/Hyper operators>
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
14 # binary infix
15 my @r;
16 my @e;
17 {
79583ce [t] moved operators/hyper.t to spec/
moritz authored
18 @r = (1, 2, 3) »+« (2, 4, 6);
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
19 @e = (3, 6, 9);
79583ce [t] moved operators/hyper.t to spec/
moritz authored
20 is(~@r, ~@e, "hyper-sum two arrays");
dcb67c2 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
moritz authored
21
79583ce [t] moved operators/hyper.t to spec/
moritz authored
22 @r = (1, 2, 3) »-« (2, 4, 6);
23 @e = (-1, -2, -3);
24 is(~@r, ~@e, "hyper-subtract two arrays");
dcb67c2 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
moritz authored
25
26 @r = (1, 2, 3) »*« (2, 4, 6);
27 @e = (2, 8, 18);
28 is(~@r, ~@e, "hyper-multiply two arrays");
29
30 @r = (1, 2, 3) »x« (3, 2, 1);
31 @e = ('111', '22', '3');
32 is(~@r, ~@e, "hyper-x two arrays");
33
34 @r = (1, 2, 3) »xx« (3, 2, 1);
35 @e = ((1,1,1), (2,2), (3));
36 is(~@r, ~@e, "hyper-xx two arrays");
37
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
38 @r = (20, 40, 60) »div« (2, 5, 10);
dcb67c2 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
moritz authored
39 @e = (10, 8, 6);
40 is(~@r, ~@e, "hyper-divide two arrays");
41
42 @r = (1, 2, 3) »+« (10, 20, 30) »*« (2, 3, 4);
43 @e = (21, 62, 123);
44 is(~@r, ~@e, "precedence - »+« vs »*«");
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
45 }
79583ce [t] moved operators/hyper.t to spec/
moritz authored
46
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
47 {
79583ce [t] moved operators/hyper.t to spec/
moritz authored
48 @r = (1, 2, 3) >>+<< (2, 4, 6);
49 @e = (3, 6, 9);
50 is(~@r, ~@e, "hyper-sum two arrays ASCII notation");
51
52 @r = (1, 2, 3) >>-<< (2, 4, 6);
53 @e = (-1, -2, -3);
54 is(~@r, ~@e, "hyper-subtract two arrays ASCII notation");
55
56 @r = (1, 2, 3) >>*<< (2, 4, 6);
57 @e = (2, 8, 18);
58 is(~@r, ~@e, "hyper-multiply two arrays ASCII notation");
59
60 @r = (1, 2, 3) >>x<< (3, 2, 1);
61 @e = ('111', '22', '3');
62 is(~@r, ~@e, "hyper-x two arrays ASCII notation");
63
64 @r = (1, 2, 3) >>xx<< (3, 2, 1);
65 @e = ((1,1,1), (2,2), (3));
66 is(~@r, ~@e, "hyper-xx two arrays ASCII notation");
67
a4ba5fd [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
moritz authored
68 @r = (20, 40, 60) >>div<< (2, 5, 10);
79583ce [t] moved operators/hyper.t to spec/
moritz authored
69 @e = (10, 8, 6);
70 is(~@r, ~@e, "hyper-divide two arrays ASCII notation");
71
72 @r = (1, 2, 3) >>+<< (10, 20, 30) >>*<< (2, 3, 4);
73 @e = (21, 62, 123);
74 is(~@r, ~@e, "precedence - >>+<< vs >>*<< ASCII notation");
75 };
76
77 { # unary postfix
78 my @r = (1, 2, 3);
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
79 @r»++;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
80 my @e = (2, 3, 4);
7347a84 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
81 #?pugs todo
82 is(~@r, ~@e, "hyper auto increment an array");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
83
84 @r = (1, 2, 3);
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
85 @r>>++;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
86 @e = (2, 3, 4);
7347a84 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
87 #?pugs todo
88 is(~@r, ~@e, "hyper auto increment an array ASCII notation");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
89 };
90
91 { # unary prefix
92 my @r;
93 @r = -« (3, 2, 1);
94 my @e = (-3, -2, -1);
95 is(~@r, ~@e, "hyper op on assignment/pipeline");
96
97 @r = -<< (3, 2, 1);
98 @e = (-3, -2, -1);
99 is(~@r, ~@e, "hyper op on assignment/pipeline ASCII notation");
100 };
101
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
102 { # dimension upgrade - ASCII
103 my @r;
104 @r = (1, 2, 3) >>+>> 1;
105 my @e = (2, 3, 4);
106 is(~@r, ~@e, "auto dimension upgrade on rhs ASCII notation");
107
108 @r = 2 <<*<< (10, 20, 30);
109 @e = (20, 40, 60);
110 is(~@r, ~@e, "auto dimension upgrade on lhs ASCII notation");
111 }
112
207f13f [t] and [t/spec]
moritz authored
113 #?rakudo todo 'list level extension'
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
114 { # extension
115 @r = (1,2,3,4) >>~>> <A B C>;
116 @e = <1A 2B 3C 4A>;
117 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
118
119 @r = (1,2,3) <<~<< <A B C D>;
120 @e = <1A 2B 3C 1D>;
121 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
122
123 @r = (1,2,3,4) >>~>> <A B>;
124 @e = <1A 2B 3A 4B>;
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
125 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
126
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
127 @r = (1,2) <<~<< <A B C D>;
128 @e = <1A 2B 1C 2D>;
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
129 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
130
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
131 @r = (1,2,3,4) >>~>> <A>;
132 @e = <1A 2A 3A 4A>;
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
133 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
134
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
135 @r = (1,) <<~<< <A B C D>;
136 @e = <1A 1B 1C 1D>;
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
137 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
138
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
139 @r = (1,2,3,4) >>~>> 'A';
140 @e = <1A 2A 3A 4A>;
141 is(~@r, ~@e, "scalar element extension on rhs ASCII notation");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
142
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
143 @r = 1 <<~<< <A B C D>;
144 @e = <1A 1B 1C 1D>;
145 is(~@r, ~@e, "scalar element extension on lhs ASCII notation");
146 };
79583ce [t] moved operators/hyper.t to spec/
moritz authored
147
fe872b9 [t/spec] Update hyper tests to match new spec.
colomon authored
148 #?rakudo todo 'unicode hypers'
149 { # dimension upgrade - unicode
150 @r = (1,2,3,4) »~» <A B C>;
151 @e = <1A 2B 3C 4A>;
152 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
153
154 @r = (1,2,3) «~« <A B C D>;
155 @e = <1A 2B 3C 1D>;
156 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
157
158 @r = (1,2,3,4) »~» <A B>;
159 @e = <1A 2B 3A 4B>;
160 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
161
162 @r = (1,2) «~« <A B C D>;
163 @e = <1A 2B 1C 2D>;
164 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
165
166 @r = (1,2,3,4) »~» <A>;
167 @e = <1A 2A 3A 4A>;
168 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
169
170 @r = (1,) «~« <A B C D>;
171 @e = <1A 1B 1C 1D>;
172 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
173
174 @r = (1,2,3,4) »~» 'A';
175 @e = <1A 2A 3A 4A>;
176 is(~@r, ~@e, "scalar element extension on rhs unicode notation");
177
178 @r = 1 «~« <A B C D>;
179 @e = <1A 1B 1C 1D>;
180 is(~@r, ~@e, "scalar element extension on lhs unicode notation");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
181 };
182
183 { # unary postfix with integers
184 my @r;
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
185 @r = (1, 4, 9)».sqrt;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
186 my @e = (1, 2, 3);
187 is(~@r, ~@e, "method call on integer list elements");
188
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
189 @r = (1, 4, 9)>>.sqrt;
1e0f570 [t/spec]: Eliminate some "Redeclared variable" warnings in tests
pmichaud authored
190 @e = (1, 2, 3);
79583ce [t] moved operators/hyper.t to spec/
moritz authored
191 is(~@r, ~@e, "method call on integer list elements (ASCII)");
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
192 }
f7dc0d5 added more missing test cases from S03
jimmy authored
193
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
194 #?rakudo skip '@array»++'
195 {
00f085f [hyper.t] missing semi
lwall authored
196 my (@r, @e);
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
197 (@r = (1, 4, 9))»++;
198 @e = (2, 5, 10);
f7dc0d5 added more missing test cases from S03
jimmy authored
199 is(~@r, ~@e, "operator call on integer list elements");
200
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
201 (@r = (1, 4, 9)).»++;
f7dc0d5 added more missing test cases from S03
jimmy authored
202 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
203
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
204 (@r = (1, 4, 9))».++;
f7dc0d5 added more missing test cases from S03
jimmy authored
205 @e = (2, 5, 9);
206 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
207
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
208 (@r = (1, 4, 9)).».++;
f7dc0d5 added more missing test cases from S03
jimmy authored
209 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
210
245fd38 [t/spec] correct and fudge @array>>++ tests in hyper.t
moritz authored
211 (@r = (1, 4, 9))\ .»\ .++;
f7dc0d5 added more missing test cases from S03
jimmy authored
212 @e = (2, 5, 9);
213 is(~@r, ~@e, "operator call on integer list elements (Same thing, upspace form)");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
214 };
215
216 { # unary postfix again, but with a twist
217 my @r;
218 eval '@r = ("f", "oo", "bar")».chars';
219 my @e = (1, 2, 3);
220 is(~@r, ~@e, "method call on list elements");
221
7acf591 [/t/spec/S03-operators/hyper.t] added missing dot
jimmy authored
222 eval '@r = ("f", "oo", "bar").».chars';
f7dc0d5 added more missing test cases from S03
jimmy authored
223 @e = (1, 2, 3);
224 is(~@r, ~@e, "method call on list elements (Same thing, dot form)");
225
226
79583ce [t] moved operators/hyper.t to spec/
moritz authored
227 eval '@r = ("f", "oo", "bar")>>.chars';
228 @e = (1, 2, 3);
229 is(~@r, ~@e, "method call on list elements (ASCII)");
f7dc0d5 added more missing test cases from S03
jimmy authored
230
231 eval '@r = ("f", "oo", "bar").>>.chars';
232 @e = (1, 2, 3);
233 is(~@r, ~@e, "method call on list elements (ASCII, Same thing, dot form)");
234
79583ce [t] moved operators/hyper.t to spec/
moritz authored
235 };
236
237 { # unary postfix on a user-defined object
238 my $t;
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
239 class FooTest { method bar { 42 } }; $t = FooTest.new.bar;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
240 is($t, 42, 'plain method call works OK');
241
242 my @r;
10f7c47 [hyper.t] dedup class
lwall authored
243 class FooTest2 { method bar { 42 } }; @r = (FooTest2.new)>>.bar;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
244 my @e = (42);
b7e4ed5 [t/spec] Unfudge some parallel dispatch tests in S03-operators/hyper.…
jnthn authored
245 is(~@r, ~@e, "hyper-method-call on list of user-defined objects");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
246 };
247
248 { # distribution for unary prefix
249 my @r;
250 @r = -« ([1, 2], [3, [4, 5]]);
251 my @e = ([-1, -2], [-3, [-4, -5]]);
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
252 is(~@r, ~@e, "distribution for unary prefix");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
253 is_deeply(@r, @e, "distribution for unary prefix, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
254
255 @r = -<< ([1, 2], [3, [4, 5]]);
256 @e = ([-1, -2], [-3, [-4, -5]]);
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
257 is(~@r, ~@e, "distribution for unary prefix, ASCII");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
258 is_deeply(@r, @e, "distribution for unary prefix, ASCII, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
259 };
260
261 { # distribution for unary postfix autoincrement
262 my @r;
263 @r = ([1, 2], [3, [4, 5]]);
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
264 @r»++;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
265 my @e = ([2, 3], [4, [5, 6]]);
7347a84 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
266 #?pugs todo
267 is(~@r, ~@e, "distribution for unary postfix autoincr");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
268 is_deeply(@r, @e, "distribution for unary postfix autoincr, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
269
270 @r = ([1, 2], [3, [4, 5]]);
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
271 @r>>++;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
272 @e = ([2, 3], [4, [5, 6]]);
7347a84 [t/spec] Change more Pugs todo flags to fudge commands
kyle authored
273 #?pugs todo
274 is(~@r, ~@e, "distribution for unary postfix autoincr, ASCII");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
275 is_deeply(@r, @e, "distribution for unary postfix autoincr, ASCII, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
276 };
277
0aedd5b [t/spec] Fudge hyper.t for Rakudo.
colomon authored
278 #?DOES 3
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
279 { # distribution for binary infix - ASCII
280 my @r;
281 @r = (1, 2, [3, 4]) >>+<< (4, 5, [6, 7]);
282 my @e = (5, 7, [9, 11]);
283 is(~@r, ~@e, "distribution for binary infix, same shape, ASCII");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
284 is_deeply(@r, @e, "distribution for binary infix, same shape, ASCII, deep comparision");
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
285
286 @r = (1, 2, [3, 4]) >>+>> (5, 6, 7);
287 @e = (6, 8, [10, 11]);
288 is(~@r, ~@e, "distribution for binary infix, dimension upgrade, ASCII");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
289 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, ASCII, deep comparison");
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
290
291 @r = ([1, 2], 3) <<+>> (4, [5, 6]);
292 @e = ([5, 6], [8, 9]);
293 is(~@r, ~@e, "distribution for binary infix, S03 cross-upgrade, ASCII");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
294 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, ASCII, deep comparison");
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
295 };
296
297 #?DOES 3
298 { # distribution for binary infix - unicode
79583ce [t] moved operators/hyper.t to spec/
moritz authored
299 my @r;
300 @r = (1, 2, [3, 4]) »+« (4, 5, [6, 7]);
301 my @e = (5, 7, [9, 11]);
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
302 is(~@r, ~@e, "distribution for binary infix, same shape");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
303 is_deeply(@r, @e, "distribution for binary infix, same shape, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
304
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
305 @r = (1, 2, [3, 4]) »+» (5, 6, 7);
79583ce [t] moved operators/hyper.t to spec/
moritz authored
306 @e = (6, 8, [10, 11]);
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
307 is(~@r, ~@e, "distribution for binary infix, dimension upgrade");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
308 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
309
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
310 @r = ([1, 2], 3) «+» (4, [5, 6]);
79583ce [t] moved operators/hyper.t to spec/
moritz authored
311 @e = ([5, 6], [8, 9]);
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
312 is(~@r, ~@e, "distribution for binary infix, S03 cross-upgrade");
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
313 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, deep comparison");
79583ce [t] moved operators/hyper.t to spec/
moritz authored
314 };
315
316 { # regression test, ensure that hyper works on arrays
317 my @r1;
318 my @r2;
319 my @e1 = (2, 4, 6);
320 my @a = (1, 2, 3);
321 @r1 = @a >>+<< @a;
322 is(~@r1, ~@e1, "hyper op works on variables, too.");
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
323 }
324 {
325 my @a = (1, 2, 3);
326 my @e2 = (2, 3, 4);
3159006 [t/spec] Correct some and unfudge some hyper spec tests.
jnthn authored
327 my @r2 = @a >>+>> 1;
79583ce [t] moved operators/hyper.t to spec/
moritz authored
328 is(~@r2, ~@e2, "hyper op and correctly promotes scalars");
329 };
330
331
332 # mixed hyper and reduce metaops -
333 # this unveils a spec bug as << recurses into arrays and [+] never gets applied,
334 # so we disable the entire chunk for now.
335 =begin todo unspecced
336
337 is ~([+]<< ([1,2,3], [4,5,6])), "6 15", "mixed hyper and reduce metaop ([+]<<) works";
338 ## XXX: Test for [+]<<<< - This is unspecced, commenting it out
339 #is ~([+]<<<< ([[1,2],[3,4]],[[5,6],[7,8]])), "3 7 11 15",
340 # "mixed double hyper and reduce metaop ([+]<<<<) works";
341
342 is ~([+]« [1,2,3], [4,5,6]), "6 15",
343 "mixed Unicode hyper and reduce metaop ([+]«) works";
344
345 =end todo unspecced
346
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
347 #?pugs todo 'hyper ops'
79583ce [t] moved operators/hyper.t to spec/
moritz authored
348 { # hyper dereferencing
349 my @array = (
350 { key => 'val' },
351 { key => 'val' },
352 { key => 'val' }
353 );
354
355 my $full = join '', eval '@array>>.<key>';
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
356 is($full, 'valvalval', 'hyper-dereference an array');
79583ce [t] moved operators/hyper.t to spec/
moritz authored
357
358 my $part = join '', eval '@array[0,1]>>.<key>';
05f901a [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
moritz authored
359 is($part, 'valval', 'hyper-dereference an array slice');
79583ce [t] moved operators/hyper.t to spec/
moritz authored
360 }
361
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
362 #?pugs todo 'feature'
79583ce [t] moved operators/hyper.t to spec/
moritz authored
363 { # junction hyper -- regression?
364 my @a = 1..3;
365 my @b = 4..6;
57c1095 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
moritz authored
366 ok ?(@a »|« @b), '»|« hyperjunction evals';
367 ok ?(@a >>|<< @b), '>>|<< hyperjunction evals, ASCII';
368 ok ?(@a »&« @b), '»&« hyperjunction evals';
84d84f4 [t/spec] Refudging and tweaks for nested hyper.
colomon authored
369 ok ?(@a >>&<< @b), '>>&<< hyperjunction evals, ASCII';
79583ce [t] moved operators/hyper.t to spec/
moritz authored
370 }
8ba3aa4 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
jnthn authored
371
372 # test hypers on hashes
373 {
374 my %a = a => 1, b => 2, c => 3;
375 my %b = a => 5, b => 6, c => 7;
376 my %c = a => 1, b => 2;
377 my %d = a => 5, b => 6;
378
379 my %r;
380 %r = %a >>+<< %b;
381 is +%r, 3, 'hash - >>+<< result has right number of keys (same keys)';
382 is %r<a>, 6, 'hash - correct result form >>+<< (same keys)';
383 is %r<b>, 8, 'hash - correct result form >>+<< (same keys)';
384 is %r<c>, 10, 'hash - correct result form >>+<< (same keys)';
385
ec15c52 [t/spec] Single-op hyper hash tests.
colomon authored
386 %r = %a »+« %d;
387 is +%r, 3, 'hash - »+« result has right number of keys (union test)';
388 is %r<a>, 6, 'hash - correct result form »+« (union test)';
389 is %r<b>, 8, 'hash - correct result form »+« (union test)';
390 is %r<c>, 3, 'hash - correct result form »+« (union test)';
8ba3aa4 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
jnthn authored
391
392 %r = %c >>+<< %b;
393 is +%r, 3, 'hash - >>+<< result has right number of keys (union test)';
394 is %r<a>, 6, 'hash - correct result form >>+<< (union test)';
395 is %r<b>, 8, 'hash - correct result form >>+<< (union test)';
396 is %r<c>, 7, 'hash - correct result form >>+<< (union test)';
397
398 %r = %a <<+>> %b;
399 is +%r, 3, 'hash - <<+>> result has right number of keys (same keys)';
400 is %r<a>, 6, 'hash - correct result form <<+>> (same keys)';
401 is %r<b>, 8, 'hash - correct result form <<+>> (same keys)';
402 is %r<c>, 10, 'hash - correct result form <<+>> (same keys)';
403
404 %r = %a <<+>> %d;
405 is +%r, 2, 'hash - <<+>> result has right number of keys (intersection test)';
406 is %r<a>, 6, 'hash - correct result form <<+>> (intersection test)';
407 is %r<b>, 8, 'hash - correct result form <<+>> (intersection test)';
408
409 %r = %c <<+>> %b;
410 is +%r, 2, 'hash - <<+>> result has right number of keys (intersection test)';
411 is %r<a>, 6, 'hash - correct result form <<+>> (intersection test)';
412 is %r<b>, 8, 'hash - correct result form <<+>> (intersection test)';
b87c0d8 [t/spec] Tests for asymmetric variants of hypers on hashes.
jnthn authored
413
414 %r = %a >>+>> %c;
415 is +%r, 3, 'hash - >>+>> result has right number of keys';
416 is %r<a>, 2, 'hash - correct result from >>+>>';
417 is %r<b>, 4, 'hash - correct result from >>+>>';
418 is %r<c>, 3, 'hash - correct result from >>+>>';
419
420 %r = %c >>+>> %b;
421 is +%r, 2, 'hash - >>+>> result has right number of keys';
422 is %r<a>, 6, 'hash - correct result from >>+>>';
423 is %r<b>, 8, 'hash - correct result from >>+>>';
424
425 %r = %c <<+<< %a;
426 is +%r, 3, 'hash - <<+<< result has right number of keys';
427 is %r<a>, 2, 'hash - correct result from <<+<<';
428 is %r<b>, 4, 'hash - correct result from <<+<<';
429 is %r<c>, 3, 'hash - correct result from <<+<<';
430
431 %r = %b <<+<< %c;
432 is +%r, 2, 'hash - <<+<< result has right number of keys';
433 is %r<a>, 6, 'hash - correct result from <<+<<';
434 is %r<b>, 8, 'hash - correct result from <<+<<';
8ba3aa4 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
jnthn authored
435 }
5adc2df [t/spec] fix hyper as-latin-1 tests
moritz authored
436
ec15c52 [t/spec] Single-op hyper hash tests.
colomon authored
437 {
438 my %a = a => 1, b => 2, c => 3;
439 my %r = -<<%a;
440 is +%r, 3, 'hash - -<< result has right number of keys';
441 is %r<a>, -1, 'hash - correct result from -<<';
442 is %r<b>, -2, 'hash - correct result from -<<';
443 is %r<c>, -3, 'hash - correct result from -<<';
444
445 %r = --<<%a;
446 is +%r, 3, 'hash - --<< result has right number of keys';
447 is %r<a>, 0, 'hash - correct result from --<<';
448 is %r<b>, 1, 'hash - correct result from --<<';
449 is %r<c>, 2, 'hash - correct result from --<<';
450 is +%a, 3, 'hash - --<< result has right number of keys';
451 is %a<a>, 0, 'hash - correct result from --<<';
452 is %a<b>, 1, 'hash - correct result from --<<';
453 is %a<c>, 2, 'hash - correct result from --<<';
454
455 %r = %a>>++;
456 is +%r, 3, 'hash - >>++ result has right number of keys';
457 is %r<a>, 0, 'hash - correct result from >>++';
458 is %r<b>, 1, 'hash - correct result from >>++';
459 is %r<c>, 2, 'hash - correct result from >>++';
460 is +%a, 3, 'hash - >>++ result has right number of keys';
461 is %a<a>, 1, 'hash - correct result from >>++';
462 is %a<b>, 2, 'hash - correct result from >>++';
463 is %a<c>, 3, 'hash - correct result from >>++';
464 }
465
466 {
467 our sub postfix:<!>($a) {
468 [*] 1..$a;
469 }
470
471 my %a = a => 1, b => 2, c => 3;
472 my %r = %a>>!;
473 is +%r, 3, 'hash - >>! result has right number of keys';
474 is %r<a>, 1, 'hash - correct result from >>!';
475 is %r<b>, 2, 'hash - correct result from >>!';
476 is %r<c>, 6, 'hash - correct result from >>!';
477 }
478
e57d81e [t/spec] Tests for mixed hash / scalar hypers.
colomon authored
479 {
480 my %a = a => 1, b => 2, c => 3;
481
482 my %r = %a >>*>> 4;
483 is +%r, 3, 'hash - >>*>> result has right number of keys';
484 is %r<a>, 4, 'hash - correct result from >>*>>';
485 is %r<b>, 8, 'hash - correct result from >>*>>';
486 is %r<c>, 12, 'hash - correct result from >>*>>';
487
488 %r = 2 <<**<< %a ;
489 is +%r, 3, 'hash - <<**<< result has right number of keys';
490 is %r<a>, 2, 'hash - correct result from <<**<<';
491 is %r<b>, 4, 'hash - correct result from <<**<<';
492 is %r<c>, 8, 'hash - correct result from <<**<<';
493
494 %r = %a <<*>> 4;
495 is +%r, 3, 'hash - <<*>> result has right number of keys';
496 is %r<a>, 4, 'hash - correct result from <<*>>';
497 is %r<b>, 8, 'hash - correct result from <<*>>';
498 is %r<c>, 12, 'hash - correct result from <<*>>';
499
500 %r = 2 <<**>> %a ;
501 is +%r, 3, 'hash - <<**>> result has right number of keys';
502 is %r<a>, 2, 'hash - correct result from <<**>>';
503 is %r<b>, 4, 'hash - correct result from <<**>>';
504 is %r<c>, 8, 'hash - correct result from <<**>>';
505 }
5adc2df [t/spec] fix hyper as-latin-1 tests
moritz authored
506
507 # test non-UTF-8 input
508 #?pugs skip 'eval(Buf)'
509 #?rakudo skip 'eval(Buf)'
01ba23e [t/spec] fudge gets confused with some tests counts, so add a #?DOES …
moritz authored
510 #?DOES 1
5adc2df [t/spec] fix hyper as-latin-1 tests
moritz authored
511 {
512 my $t = '(1, 2, 3) »+« (4, 3, 2)';
513 ok !eval($t.encode('ISO-8859-1')),
514 'Latin-1 »+« without pre-declaration is an error';
515 }
516
0aedd5b [t/spec] Fudge hyper.t for Rakudo.
colomon authored
517 done_testing;
518
5adc2df [t/spec] fix hyper as-latin-1 tests
moritz authored
519 # vim: ft=perl6
Something went wrong with that request. Please try again.