Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 520 lines (419 sloc) 17.259 kb
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 Hyper operators L<S03/"Hyper operators">
8
9 =end pod
10
0aedd5bc »
2010-03-22 [t/spec] Fudge hyper.t for Rakudo.
11 plan *;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
12
13 # L<S03/Hyper operators>
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
14 # binary infix
15 my @r;
16 my @e;
17 {
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
18 @r = (1, 2, 3) »+« (2, 4, 6);
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
19 @e = (3, 6, 9);
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
20 is(~@r, ~@e, "hyper-sum two arrays");
dcb67c2b »
2008-12-09 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
21
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
22 @r = (1, 2, 3) »-« (2, 4, 6);
23 @e = (-1, -2, -3);
24 is(~@r, ~@e, "hyper-subtract two arrays");
dcb67c2b »
2008-12-09 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
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
a4ba5fd8 »
2009-09-01 [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
38 @r = (20, 40, 60) »div« (2, 5, 10);
dcb67c2b »
2008-12-09 [t/spec] group tests in hyper.t by Unicodeness to avoid too many fudg…
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 »*«");
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
45 }
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
46
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
47 {
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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
a4ba5fd8 »
2009-09-01 [t/spec] correct meaning of infix:<div> and infix:</>. Patch courtesy…
68 @r = (20, 40, 60) >>div<< (2, 5, 10);
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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);
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
79 @r»++;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
80 my @e = (2, 3, 4);
7347a841 »
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
81 #?pugs todo
82 is(~@r, ~@e, "hyper auto increment an array");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
83
84 @r = (1, 2, 3);
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
85 @r>>++;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
86 @e = (2, 3, 4);
7347a841 »
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
87 #?pugs todo
88 is(~@r, ~@e, "hyper auto increment an array ASCII notation");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
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
207f13f6 »
2008-12-25 [t] and [t/spec]
113 #?rakudo todo 'list level extension'
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
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>;
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
125 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
126
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
127 @r = (1,2) <<~<< <A B C D>;
128 @e = <1A 2B 1C 2D>;
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
129 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
130
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
131 @r = (1,2,3,4) >>~>> <A>;
132 @e = <1A 2A 3A 4A>;
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
133 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
134
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
135 @r = (1,) <<~<< <A B C D>;
136 @e = <1A 1B 1C 1D>;
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
137 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
138
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
139 @r = (1,2,3,4) >>~>> 'A';
140 @e = <1A 2A 3A 4A>;
141 is(~@r, ~@e, "scalar element extension on rhs ASCII notation");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
142
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
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 };
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
147
fe872b95 »
2010-06-03 [t/spec] Update hyper tests to match new spec.
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");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
181 };
182
183 { # unary postfix with integers
184 my @r;
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
185 @r = (1, 4, 9)».sqrt;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
186 my @e = (1, 2, 3);
187 is(~@r, ~@e, "method call on integer list elements");
188
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
189 @r = (1, 4, 9)>>.sqrt;
1e0f5704 »
2008-12-29 [t/spec]: Eliminate some "Redeclared variable" warnings in tests
190 @e = (1, 2, 3);
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
191 is(~@r, ~@e, "method call on integer list elements (ASCII)");
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
192 }
f7dc0d58 »
2009-08-01 added more missing test cases from S03
193
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
194 #?rakudo skip '@array»++'
195 {
00f085fe »
2009-08-05 [hyper.t] missing semi
196 my (@r, @e);
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
197 (@r = (1, 4, 9))»++;
198 @e = (2, 5, 10);
f7dc0d58 »
2009-08-01 added more missing test cases from S03
199 is(~@r, ~@e, "operator call on integer list elements");
200
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
201 (@r = (1, 4, 9)).»++;
f7dc0d58 »
2009-08-01 added more missing test cases from S03
202 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
203
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
204 (@r = (1, 4, 9))».++;
f7dc0d58 »
2009-08-01 added more missing test cases from S03
205 @e = (2, 5, 9);
206 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
207
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
208 (@r = (1, 4, 9)).».++;
f7dc0d58 »
2009-08-01 added more missing test cases from S03
209 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
210
245fd38a »
2009-08-02 [t/spec] correct and fudge @array>>++ tests in hyper.t
211 (@r = (1, 4, 9))\ .»\ .++;
f7dc0d58 »
2009-08-01 added more missing test cases from S03
212 @e = (2, 5, 9);
213 is(~@r, ~@e, "operator call on integer list elements (Same thing, upspace form)");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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
7acf5915 »
2009-08-01 [/t/spec/S03-operators/hyper.t] added missing dot
222 eval '@r = ("f", "oo", "bar").».chars';
f7dc0d58 »
2009-08-01 added more missing test cases from S03
223 @e = (1, 2, 3);
224 is(~@r, ~@e, "method call on list elements (Same thing, dot form)");
225
226
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
227 eval '@r = ("f", "oo", "bar")>>.chars';
228 @e = (1, 2, 3);
229 is(~@r, ~@e, "method call on list elements (ASCII)");
f7dc0d58 »
2009-08-01 added more missing test cases from S03
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
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
235 };
236
237 { # unary postfix on a user-defined object
238 my $t;
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
239 class FooTest { method bar { 42 } }; $t = FooTest.new.bar;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
240 is($t, 42, 'plain method call works OK');
241
242 my @r;
10f7c47c »
2009-04-30 [hyper.t] dedup class
243 class FooTest2 { method bar { 42 } }; @r = (FooTest2.new)>>.bar;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
244 my @e = (42);
b7e4ed54 »
2009-05-12 [t/spec] Unfudge some parallel dispatch tests in S03-operators/hyper.…
245 is(~@r, ~@e, "hyper-method-call on list of user-defined objects");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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]]);
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
252 is(~@r, ~@e, "distribution for unary prefix");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
253 is_deeply(@r, @e, "distribution for unary prefix, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
254
255 @r = -<< ([1, 2], [3, [4, 5]]);
256 @e = ([-1, -2], [-3, [-4, -5]]);
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
257 is(~@r, ~@e, "distribution for unary prefix, ASCII");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
258 is_deeply(@r, @e, "distribution for unary prefix, ASCII, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
259 };
260
261 { # distribution for unary postfix autoincrement
262 my @r;
263 @r = ([1, 2], [3, [4, 5]]);
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
264 @r»++;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
265 my @e = ([2, 3], [4, [5, 6]]);
7347a841 »
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
266 #?pugs todo
267 is(~@r, ~@e, "distribution for unary postfix autoincr");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
268 is_deeply(@r, @e, "distribution for unary postfix autoincr, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
269
270 @r = ([1, 2], [3, [4, 5]]);
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
271 @r>>++;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
272 @e = ([2, 3], [4, [5, 6]]);
7347a841 »
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
273 #?pugs todo
274 is(~@r, ~@e, "distribution for unary postfix autoincr, ASCII");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
275 is_deeply(@r, @e, "distribution for unary postfix autoincr, ASCII, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
276 };
277
0aedd5bc »
2010-03-22 [t/spec] Fudge hyper.t for Rakudo.
278 #?DOES 3
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
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");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
284 is_deeply(@r, @e, "distribution for binary infix, same shape, ASCII, deep comparision");
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
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");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
289 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, ASCII, deep comparison");
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
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");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
294 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, ASCII, deep comparison");
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
295 };
296
297 #?DOES 3
298 { # distribution for binary infix - unicode
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
299 my @r;
300 @r = (1, 2, [3, 4]) »+« (4, 5, [6, 7]);
301 my @e = (5, 7, [9, 11]);
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
302 is(~@r, ~@e, "distribution for binary infix, same shape");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
303 is_deeply(@r, @e, "distribution for binary infix, same shape, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
304
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
305 @r = (1, 2, [3, 4]) »+» (5, 6, 7);
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
306 @e = (6, 8, [10, 11]);
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
307 is(~@r, ~@e, "distribution for binary infix, dimension upgrade");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
308 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
309
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
310 @r = ([1, 2], 3) «+» (4, [5, 6]);
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
311 @e = ([5, 6], [8, 9]);
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
312 is(~@r, ~@e, "distribution for binary infix, S03 cross-upgrade");
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
313 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, deep comparison");
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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.");
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
323 }
324 {
325 my @a = (1, 2, 3);
326 my @e2 = (2, 3, 4);
3159006d »
2008-12-09 [t/spec] Correct some and unfudge some hyper spec tests.
327 my @r2 = @a >>+>> 1;
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
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
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
347 #?pugs todo 'hyper ops'
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
348 { # hyper dereferencing
349 my @array = (
350 { key => 'val' },
351 { key => 'val' },
352 { key => 'val' }
353 );
354
355 my $full = join '', eval '@array>>.<key>';
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
356 is($full, 'valvalval', 'hyper-dereference an array');
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
357
358 my $part = join '', eval '@array[0,1]>>.<key>';
05f901ad »
2008-10-08 [t/spec] some s/is_deeply/is/ in hyper.t. azawawi++ for noticing
359 is($part, 'valval', 'hyper-dereference an array slice');
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
360 }
361
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
362 #?pugs todo 'feature'
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
363 { # junction hyper -- regression?
364 my @a = 1..3;
365 my @b = 4..6;
57c1095c »
2008-12-09 [t/spec] clean up hyper.t a bit, and fudge some tests for rakudo
366 ok ?(@a »|« @b), '»|« hyperjunction evals';
367 ok ?(@a >>|<< @b), '>>|<< hyperjunction evals, ASCII';
368 ok ?(@a »&« @b), '»&« hyperjunction evals';
84d84f49 »
2010-05-31 [t/spec] Refudging and tweaks for nested hyper.
369 ok ?(@a >>&<< @b), '>>&<< hyperjunction evals, ASCII';
79583ce0 »
2008-09-04 [t] moved operators/hyper.t to spec/
370 }
8ba3aa48 »
2009-05-09 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
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
ec15c52d »
2010-05-31 [t/spec] Single-op hyper hash tests.
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)';
8ba3aa48 »
2009-05-09 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
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)';
b87c0d8d »
2009-05-09 [t/spec] Tests for asymmetric variants of hypers on hashes.
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 <<+<<';
8ba3aa48 »
2009-05-09 [t/spec] Tests for symmetric cases of hyper operatorss on hashes.
435 }
5adc2df8 »
2009-07-14 [t/spec] fix hyper as-latin-1 tests
436
ec15c52d »
2010-05-31 [t/spec] Single-op hyper hash tests.
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
e57d81e9 »
2010-06-01 [t/spec] Tests for mixed hash / scalar hypers.
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 }
5adc2df8 »
2009-07-14 [t/spec] fix hyper as-latin-1 tests
506
507 # test non-UTF-8 input
508 #?pugs skip 'eval(Buf)'
509 #?rakudo skip 'eval(Buf)'
01ba23ec »
2009-07-15 [t/spec] fudge gets confused with some tests counts, so add a #?DOES …
510 #?DOES 1
5adc2df8 »
2009-07-14 [t/spec] fix hyper as-latin-1 tests
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
0aedd5bc »
2010-03-22 [t/spec] Fudge hyper.t for Rakudo.
517 done_testing;
518
5adc2df8 »
2009-07-14 [t/spec] fix hyper as-latin-1 tests
519 # vim: ft=perl6
Something went wrong with that request. Please try again.