7 Hyper operators L<S03/"Hyper operators">
13 # L<S03/Hyper operators>
18 @r = (1, 2, 3) »+« (2, 4, 6);
20 is(~@r, ~@e, "hyper-sum two arrays");
22 @r = (1, 2, 3) »-« (2, 4, 6);
24 is(~@r, ~@e, "hyper-subtract two arrays");
26 @r = (1, 2, 3) »*« (2, 4, 6);
28 is(~@r, ~@e, "hyper-multiply two arrays");
30 @r = (1, 2, 3) »x« (3, 2, 1);
31 @e = ('111', '22', '3');
32 is(~@r, ~@e, "hyper-x two arrays");
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");
38 @r = (20, 40, 60) »div« (2, 5, 10);
40 is(~@r, ~@e, "hyper-divide two arrays");
42 @r = (1, 2, 3) »+« (10, 20, 30) »*« (2, 3, 4);
44 is(~@r, ~@e, "precedence - »+« vs »*«");
48 @r = (1, 2, 3) >>+<< (2, 4, 6);
50 is(~@r, ~@e, "hyper-sum two arrays ASCII notation");
52 @r = (1, 2, 3) >>-<< (2, 4, 6);
54 is(~@r, ~@e, "hyper-subtract two arrays ASCII notation");
56 @r = (1, 2, 3) >>*<< (2, 4, 6);
58 is(~@r, ~@e, "hyper-multiply two arrays ASCII notation");
60 @r = (1, 2, 3) >>x<< (3, 2, 1);
61 @e = ('111', '22', '3');
62 is(~@r, ~@e, "hyper-x two arrays ASCII notation");
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");
68 @r = (20, 40, 60) >>div<< (2, 5, 10);
70 is(~@r, ~@e, "hyper-divide two arrays ASCII notation");
72 @r = (1, 2, 3) >>+<< (10, 20, 30) >>*<< (2, 3, 4);
74 is(~@r, ~@e, "precedence - >>+<< vs >>*<< ASCII notation");
82 is(~@r, ~@e, "hyper auto increment an array");
88 is(~@r, ~@e, "hyper auto increment an array ASCII notation");
95 is(~@r, ~@e, "hyper op on assignment/pipeline");
99 is(~@r, ~@e, "hyper op on assignment/pipeline ASCII notation");
102 { # dimension upgrade - ASCII
104 @r = (1, 2, 3) >>+>> 1;
106 is(~@r, ~@e, "auto dimension upgrade on rhs ASCII notation");
108 @r = 2 <<*<< (10, 20, 30);
110 is(~@r, ~@e, "auto dimension upgrade on lhs ASCII notation");
114 @r = (1,2,3,4) >>~>> <A B C D E>;
116 is(~@r, ~@e, "list-level element truncate on rhs ASCII notation");
118 @r = (1,2,3,4,5) <<~<< <A B C D>;
120 is(~@r, ~@e, "list-level element truncate on lhs ASCII notation");
122 @r = (1,2,3,4) >>~>> <A B C>;
124 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
126 @r = (1,2,3) <<~<< <A B C D>;
128 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
130 @r = (1,2,3,4) >>~>> <A B>;
132 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
134 @r = (1,2) <<~<< <A B C D>;
136 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
138 @r = (1,2,3,4) >>~>> <A>;
140 is(~@r, ~@e, "list-level element extension on rhs ASCII notation");
142 @r = (1,) <<~<< <A B C D>;
144 is(~@r, ~@e, "list-level element extension on lhs ASCII notation");
146 @r = (1,2,3,4) >>~>> 'A';
148 is(~@r, ~@e, "scalar element extension on rhs ASCII notation");
150 @r = 1 <<~<< <A B C D>;
152 is(~@r, ~@e, "scalar element extension on lhs ASCII notation");
155 { # dimension upgrade - unicode
156 @r = (1,2,3,4) »~» <A B C D E>;
158 is(~@r, ~@e, "list-level element truncate on rhs unicode notation");
160 @r = (1,2,3,4,5) «~« <A B C D>;
162 is(~@r, ~@e, "list-level element truncate on lhs unicode notation");
164 @r = (1,2,3,4) »~» <A B C>;
166 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
168 @r = (1,2,3) «~« <A B C D>;
170 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
172 @r = (1,2,3,4) »~» <A B>;
174 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
176 @r = (1,2) «~« <A B C D>;
178 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
180 @r = (1,2,3,4) »~» <A>;
182 is(~@r, ~@e, "list-level element extension on rhs unicode notation");
184 @r = (1,) «~« <A B C D>;
186 is(~@r, ~@e, "list-level element extension on lhs unicode notation");
188 @r = (1,2,3,4) »~» 'A';
190 is(~@r, ~@e, "scalar element extension on rhs unicode notation");
192 @r = 1 «~« <A B C D>;
194 is(~@r, ~@e, "scalar element extension on lhs unicode notation");
197 { # unary postfix with integers
199 @r = (1, 4, 9)».sqrt;
201 is(~@r, ~@e, "method call on integer list elements");
203 @r = (1, 4, 9)>>.sqrt;
205 is(~@r, ~@e, "method call on integer list elements (ASCII)");
208 #?rakudo skip '@array»++'
213 is(~@r, ~@e, "operator call on integer list elements");
215 (@r = (1, 4, 9)).»++;
216 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
218 (@r = (1, 4, 9))».++;
220 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
222 (@r = (1, 4, 9)).».++;
223 is(~@r, ~@e, "operator call on integer list elements (Same thing, dot form)");
225 (@r = (1, 4, 9))\ .»\ .++;
227 is(~@r, ~@e, "operator call on integer list elements (Same thing, upspace form)");
230 { # unary postfix again, but with a twist
232 eval '@r = ("f", "oo", "bar")».chars';
234 is(~@r, ~@e, "method call on list elements");
236 eval '@r = ("f", "oo", "bar").».chars';
238 is(~@r, ~@e, "method call on list elements (Same thing, dot form)");
241 eval '@r = ("f", "oo", "bar")>>.chars';
243 is(~@r, ~@e, "method call on list elements (ASCII)");
245 eval '@r = ("f", "oo", "bar").>>.chars';
247 is(~@r, ~@e, "method call on list elements (ASCII, Same thing, dot form)");
251 { # unary postfix on a user-defined object
253 class FooTest { method bar { 42 } }; $t = FooTest.new.bar;
254 is($t, 42, 'plain method call works OK');
257 class FooTest2 { method bar { 42 } }; @r = (FooTest2.new)>>.bar;
259 is(~@r, ~@e, "hyper-method-call on list of user-defined objects");
262 { # distribution for unary prefix
264 @r = -« ([1, 2], [3, [4, 5]]);
265 my @e = ([-1, -2], [-3, [-4, -5]]);
266 is(~@r, ~@e, "distribution for unary prefix");
267 is_deeply(@r, @e, "distribution for unary prefix, deep comparison");
269 @r = -<< ([1, 2], [3, [4, 5]]);
270 @e = ([-1, -2], [-3, [-4, -5]]);
271 is(~@r, ~@e, "distribution for unary prefix, ASCII");
272 is_deeply(@r, @e, "distribution for unary prefix, ASCII, deep comparison");
275 { # distribution for unary postfix autoincrement
277 @r = ([1, 2], [3, [4, 5]]);
279 my @e = ([2, 3], [4, [5, 6]]);
281 is(~@r, ~@e, "distribution for unary postfix autoincr");
282 is_deeply(@r, @e, "distribution for unary postfix autoincr, deep comparison");
284 @r = ([1, 2], [3, [4, 5]]);
286 @e = ([2, 3], [4, [5, 6]]);
288 is(~@r, ~@e, "distribution for unary postfix autoincr, ASCII");
289 is_deeply(@r, @e, "distribution for unary postfix autoincr, ASCII, deep comparison");
293 { # distribution for binary infix - ASCII
295 @r = (1, 2, [3, 4]) >>+<< (4, 5, [6, 7]);
296 my @e = (5, 7, [9, 11]);
297 is(~@r, ~@e, "distribution for binary infix, same shape, ASCII");
298 is_deeply(@r, @e, "distribution for binary infix, same shape, ASCII, deep comparision");
300 @r = (1, 2, [3, 4]) >>+>> (5, 6, 7);
301 @e = (6, 8, [10, 11]);
302 is(~@r, ~@e, "distribution for binary infix, dimension upgrade, ASCII");
303 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, ASCII, deep comparison");
305 @r = ([1, 2], 3) <<+>> (4, [5, 6]);
306 @e = ([5, 6], [8, 9]);
307 is(~@r, ~@e, "distribution for binary infix, S03 cross-upgrade, ASCII");
308 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, ASCII, deep comparison");
312 { # distribution for binary infix - unicode
314 @r = (1, 2, [3, 4]) »+« (4, 5, [6, 7]);
315 my @e = (5, 7, [9, 11]);
316 is(~@r, ~@e, "distribution for binary infix, same shape");
317 is_deeply(@r, @e, "distribution for binary infix, same shape, deep comparison");
319 @r = (1, 2, [3, 4]) »+» (5, 6, 7);
320 @e = (6, 8, [10, 11]);
321 is(~@r, ~@e, "distribution for binary infix, dimension upgrade");
322 is_deeply(@r, @e, "distribution for binary infix, dimension upgrade, deep comparison");
324 @r = ([1, 2], 3) «+» (4, [5, 6]);
325 @e = ([5, 6], [8, 9]);
326 is(~@r, ~@e, "distribution for binary infix, S03 cross-upgrade");
327 is_deeply(@r, @e, "distribution for binary infix, S03 cross-upgrade, deep comparison");
330 { # regression test, ensure that hyper works on arrays
336 is(~@r1, ~@e1, "hyper op works on variables, too.");
342 is(~@r2, ~@e2, "hyper op and correctly promotes scalars");
346 # mixed hyper and reduce metaops -
347 # this unveils a spec bug as << recurses into arrays and [+] never gets applied,
348 # so we disable the entire chunk for now.
349 =begin todo unspecced
351 is ~([+]<< ([1,2,3], [4,5,6])), "6 15", "mixed hyper and reduce metaop ([+]<<) works";
352 ## XXX: Test for [+]<<<< - This is unspecced, commenting it out
353 #is ~([+]<<<< ([[1,2],[3,4]],[[5,6],[7,8]])), "3 7 11 15",
354 # "mixed double hyper and reduce metaop ([+]<<<<) works";
356 is ~([+]« [1,2,3], [4,5,6]), "6 15",
357 "mixed Unicode hyper and reduce metaop ([+]«) works";
361 #?pugs todo 'hyper ops'
362 { # hyper dereferencing
369 my $full = join '', eval '@array>>.<key>';
370 is($full, 'valvalval', 'hyper-dereference an array');
372 my $part = join '', eval '@array[0,1]>>.<key>';
373 is($part, 'valval', 'hyper-dereference an array slice');
376 #?pugs todo 'feature'
377 { # junction hyper -- regression?
380 ok ?(@a »|« @b), '»|« hyperjunction evals';
381 ok ?(@a >>|<< @b), '>>|<< hyperjunction evals, ASCII';
382 ok ?(@a »&« @b), '»&« hyperjunction evals';
383 ok ?(@a >>&<< @b), '>>&<< hyperjunction evals, ASCII';
386 # test hypers on hashes
388 my %a = a => 1, b => 2, c => 3;
389 my %b = a => 5, b => 6, c => 7;
390 my %c = a => 1, b => 2;
391 my %d = a => 5, b => 6;
395 is +%r, 3, 'hash - >>+<< result has right number of keys (same keys)';
396 is %r<a>, 6, 'hash - correct result form >>+<< (same keys)';
397 is %r<b>, 8, 'hash - correct result form >>+<< (same keys)';
398 is %r<c>, 10, 'hash - correct result form >>+<< (same keys)';
401 is +%r, 3, 'hash - »+« result has right number of keys (union test)';
402 is %r<a>, 6, 'hash - correct result form »+« (union test)';
403 is %r<b>, 8, 'hash - correct result form »+« (union test)';
404 is %r<c>, 3, 'hash - correct result form »+« (union test)';
407 is +%r, 3, 'hash - >>+<< result has right number of keys (union test)';
408 is %r<a>, 6, 'hash - correct result form >>+<< (union test)';
409 is %r<b>, 8, 'hash - correct result form >>+<< (union test)';
410 is %r<c>, 7, 'hash - correct result form >>+<< (union test)';
413 is +%r, 3, 'hash - <<+>> result has right number of keys (same keys)';
414 is %r<a>, 6, 'hash - correct result form <<+>> (same keys)';
415 is %r<b>, 8, 'hash - correct result form <<+>> (same keys)';
416 is %r<c>, 10, 'hash - correct result form <<+>> (same keys)';
419 is +%r, 2, 'hash - <<+>> result has right number of keys (intersection test)';
420 is %r<a>, 6, 'hash - correct result form <<+>> (intersection test)';
421 is %r<b>, 8, 'hash - correct result form <<+>> (intersection test)';
424 is +%r, 2, 'hash - <<+>> result has right number of keys (intersection test)';
425 is %r<a>, 6, 'hash - correct result form <<+>> (intersection test)';
426 is %r<b>, 8, 'hash - correct result form <<+>> (intersection test)';
429 is +%r, 3, 'hash - >>+>> result has right number of keys';
430 is %r<a>, 2, 'hash - correct result from >>+>>';
431 is %r<b>, 4, 'hash - correct result from >>+>>';
432 is %r<c>, 3, 'hash - correct result from >>+>>';
435 is +%r, 2, 'hash - >>+>> result has right number of keys';
436 is %r<a>, 6, 'hash - correct result from >>+>>';
437 is %r<b>, 8, 'hash - correct result from >>+>>';
440 is +%r, 3, 'hash - <<+<< result has right number of keys';
441 is %r<a>, 2, 'hash - correct result from <<+<<';
442 is %r<b>, 4, 'hash - correct result from <<+<<';
443 is %r<c>, 3, 'hash - correct result from <<+<<';
446 is +%r, 2, 'hash - <<+<< result has right number of keys';
447 is %r<a>, 6, 'hash - correct result from <<+<<';
448 is %r<b>, 8, 'hash - correct result from <<+<<';
452 my %a = a => 1, b => 2, c => 3;
454 is +%r, 3, 'hash - -<< result has right number of keys';
455 is %r<a>, -1, 'hash - correct result from -<<';
456 is %r<b>, -2, 'hash - correct result from -<<';
457 is %r<c>, -3, 'hash - correct result from -<<';
460 is +%r, 3, 'hash - --<< result has right number of keys';
461 is %r<a>, 0, 'hash - correct result from --<<';
462 is %r<b>, 1, 'hash - correct result from --<<';
463 is %r<c>, 2, 'hash - correct result from --<<';
464 is +%a, 3, 'hash - --<< result has right number of keys';
465 is %a<a>, 0, 'hash - correct result from --<<';
466 is %a<b>, 1, 'hash - correct result from --<<';
467 is %a<c>, 2, 'hash - correct result from --<<';
470 is +%r, 3, 'hash - >>++ result has right number of keys';
471 is %r<a>, 0, 'hash - correct result from >>++';
472 is %r<b>, 1, 'hash - correct result from >>++';
473 is %r<c>, 2, 'hash - correct result from >>++';
474 is +%a, 3, 'hash - >>++ result has right number of keys';
475 is %a<a>, 1, 'hash - correct result from >>++';
476 is %a<b>, 2, 'hash - correct result from >>++';
477 is %a<c>, 3, 'hash - correct result from >>++';
481 our sub postfix:<!>($a) {
485 my %a = a => 1, b => 2, c => 3;
487 is +%r, 3, 'hash - >>! result has right number of keys';
488 is %r<a>, 1, 'hash - correct result from >>!';
489 is %r<b>, 2, 'hash - correct result from >>!';
490 is %r<c>, 6, 'hash - correct result from >>!';
494 my %a = a => 1, b => 2, c => 3;
497 is +%r, 3, 'hash - >>*>> result has right number of keys';
498 is %r<a>, 4, 'hash - correct result from >>*>>';
499 is %r<b>, 8, 'hash - correct result from >>*>>';
500 is %r<c>, 12, 'hash - correct result from >>*>>';
503 is +%r, 3, 'hash - <<**<< result has right number of keys';
504 is %r<a>, 2, 'hash - correct result from <<**<<';
505 is %r<b>, 4, 'hash - correct result from <<**<<';
506 is %r<c>, 8, 'hash - correct result from <<**<<';
509 is +%r, 3, 'hash - <<*>> result has right number of keys';
510 is %r<a>, 4, 'hash - correct result from <<*>>';
511 is %r<b>, 8, 'hash - correct result from <<*>>';
512 is %r<c>, 12, 'hash - correct result from <<*>>';
515 is +%r, 3, 'hash - <<**>> result has right number of keys';
516 is %r<a>, 2, 'hash - correct result from <<**>>';
517 is %r<b>, 4, 'hash - correct result from <<**>>';
518 is %r<c>, 8, 'hash - correct result from <<**>>';
521 #?rakudo skip '>>. NYI on hashes'
523 my %a = a => 1, b => -2, c => 3;
525 is +%r, 3, 'hash - >>.abs result has right number of keys';
526 is %r<a>, 1, 'hash - correct result from >>.abs';
527 is %r<b>, 2, 'hash - correct result from >>.abs';
528 is %r<c>, 3, 'hash - correct result from >>.abs';
532 my @a = (1, { a => 2, b => 3 }, 4);
534 my @c = ('z', { a => 'y', b => 'x' }, 'w');
538 is +@r, 3, 'hash in array - result array is the correct length';
539 is @r[0], "1a", 'hash in array - correct result from <<~>>';
540 is @r[1]<a>, "2b", 'hash in array - correct result from <<~>>';
541 is @r[1]<b>, "3b", 'hash in array - correct result from <<~>>';
542 is @r[2], "4c", 'hash in array - correct result from <<~>>';
545 is +@r, 3, 'hash in array - result array is the correct length';
546 is @r[0], "1z", 'hash in array - correct result from >>~<<';
547 is @r[1]<a>, "2y", 'hash in array - correct result from >>~<<';
548 is @r[1]<b>, "3x", 'hash in array - correct result from >>~<<';
549 is @r[2], "4w", 'hash in array - correct result from >>~<<';
552 is +@r, 3, 'hash in array - result array is the correct length';
553 is @r[0], "1a", 'hash in array - correct result from >>~>>';
554 is @r[1]<a>, "2b", 'hash in array - correct result from >>~>>';
555 is @r[1]<b>, "3b", 'hash in array - correct result from >>~>>';
556 is @r[2], "4c", 'hash in array - correct result from >>~>>';
559 is +@r, 3, 'hash in array - result array is the correct length';
560 is @r[0], "1a", 'hash in array - correct result from <<R~<<';
561 is @r[1]<a>, "2b", 'hash in array - correct result from <<R~<<';
562 is @r[1]<b>, "3b", 'hash in array - correct result from <<R~<<';
563 is @r[2], "4c", 'hash in array - correct result from <<R~<<';
566 is +@r, 6, 'hash in array - result array is the correct length';
567 is @r[0], "1a", 'hash in array - correct result from <<~>>';
568 is @r[1]<a>, "2b", 'hash in array - correct result from <<~>>';
569 is @r[1]<b>, "3b", 'hash in array - correct result from <<~>>';
570 is @r[2], "4c", 'hash in array - correct result from <<~>>';
571 is @r[3], "1d", 'hash in array - correct result from <<~>>';
572 is @r[4]<a>, "2e", 'hash in array - correct result from <<~>>';
573 is @r[4]<b>, "3e", 'hash in array - correct result from <<~>>';
574 is @r[5], "4f", 'hash in array - correct result from <<~>>';
578 my @a = (1, { a => 2, b => 3 }, 4);
580 my @c = ('z', { a => 'y', b => 'x' }, 'w');
584 is +@r, 3, 'hash in array - result array is the correct length';
585 is @r[0], "1a", 'hash in array - correct result from «~»';
586 is @r[1]<a>, "2b", 'hash in array - correct result from «~»';
587 is @r[1]<b>, "3b", 'hash in array - correct result from «~»';
588 is @r[2], "4c", 'hash in array - correct result from «~»';
591 is +@r, 3, 'hash in array - result array is the correct length';
592 is @r[0], "1z", 'hash in array - correct result from »~«';
593 is @r[1]<a>, "2y", 'hash in array - correct result from »~«';
594 is @r[1]<b>, "3x", 'hash in array - correct result from »~«';
595 is @r[2], "4w", 'hash in array - correct result from »~«';
598 is +@r, 3, 'hash in array - result array is the correct length';
599 is @r[0], "1a", 'hash in array - correct result from »~»';
600 is @r[1]<a>, "2b", 'hash in array - correct result from »~»';
601 is @r[1]<b>, "3b", 'hash in array - correct result from »~»';
602 is @r[2], "4c", 'hash in array - correct result from »~»';
605 is +@r, 3, 'hash in array - result array is the correct length';
606 is @r[0], "1a", 'hash in array - correct result from «R~«';
607 is @r[1]<a>, "2b", 'hash in array - correct result from «R~«';
608 is @r[1]<b>, "3b", 'hash in array - correct result from «R~«';
609 is @r[2], "4c", 'hash in array - correct result from «R~«';
612 is +@r, 6, 'hash in array - result array is the correct length';
613 is @r[0], "1a", 'hash in array - correct result from «~»';
614 is @r[1]<a>, "2b", 'hash in array - correct result from «~»';
615 is @r[1]<b>, "3b", 'hash in array - correct result from «~»';
616 is @r[2], "4c", 'hash in array - correct result from «~»';
617 is @r[3], "1d", 'hash in array - correct result from «~»';
618 is @r[4]<a>, "2e", 'hash in array - correct result from «~»';
619 is @r[4]<b>, "3e", 'hash in array - correct result from «~»';
620 is @r[5], "4f", 'hash in array - correct result from «~»';
624 my @a = (1, { a => 2, b => 3 }, 4);
626 is +@r, 3, 'hash in array - result array is the correct length';
627 is @r[0], -1, 'hash in array - correct result from -<<';
628 is @r[1]<a>, -2, 'hash in array - correct result from -<<';
629 is @r[1]<b>, -3, 'hash in array - correct result from -<<';
630 is @r[2], -4, 'hash in array - correct result from -<<';
633 is +@r, 3, 'hash in array - result array is the correct length';
634 is @r[0], 2, 'hash in array - correct result from ++<<';
635 is @r[1]<a>, 3, 'hash in array - correct result from ++<<';
636 is @r[1]<b>, 4, 'hash in array - correct result from ++<<';
637 is @r[2], 5, 'hash in array - correct result from ++<<';
640 is +@r, 3, 'hash in array - result array is the correct length';
641 is @r[0], 2, 'hash in array - correct result from ++<<';
642 is @r[1]<a>, 3, 'hash in array - correct result from ++<<';
643 is @r[1]<b>, 4, 'hash in array - correct result from ++<<';
644 is @r[2], 5, 'hash in array - correct result from ++<<';
645 is +@a, 3, 'hash in array - result array is the correct length';
646 is @a[0], 1, 'hash in array - correct result from ++<<';
647 is @a[1]<a>, 2, 'hash in array - correct result from ++<<';
648 is @a[1]<b>, 3, 'hash in array - correct result from ++<<';
649 is @a[2], 4, 'hash in array - correct result from ++<<';
653 my @a = (1, { a => 2, b => 3 }, 4);
655 is +@r, 3, 'hash in array - result array is the correct length';
656 is @r[0], -1, 'hash in array - correct result from -«';
657 is @r[1]<a>, -2, 'hash in array - correct result from -«';
658 is @r[1]<b>, -3, 'hash in array - correct result from -«';
659 is @r[2], -4, 'hash in array - correct result from -«';
662 is +@r, 3, 'hash in array - result array is the correct length';
663 is @r[0], 2, 'hash in array - correct result from ++«';
664 is @r[1]<a>, 3, 'hash in array - correct result from ++«';
665 is @r[1]<b>, 4, 'hash in array - correct result from ++«';
666 is @r[2], 5, 'hash in array - correct result from ++«';
669 is +@r, 3, 'hash in array - result array is the correct length';
670 is @r[0], 2, 'hash in array - correct result from ++«';
671 is @r[1]<a>, 3, 'hash in array - correct result from ++«';
672 is @r[1]<b>, 4, 'hash in array - correct result from ++«';
673 is @r[2], 5, 'hash in array - correct result from ++«';
674 is +@a, 3, 'hash in array - result array is the correct length';
675 is @a[0], 1, 'hash in array - correct result from ++«';
676 is @a[1]<a>, 2, 'hash in array - correct result from ++«';
677 is @a[1]<b>, 3, 'hash in array - correct result from ++«';
678 is @a[2], 4, 'hash in array - correct result from ++«';
681 # test non-UTF-8 input
682 #?pugs skip 'eval(Buf)'
683 #?rakudo skip 'eval(Buf)'
686 my $t = '(1, 2, 3) »+« (4, 3, 2)';
687 ok !eval($t.encode('ISO-8859-1')),
688 'Latin-1 »+« without pre-declaration is an error';
691 # L<S03/"Hyper operators"/is assumed to be infinitely extensible>
692 #?rakudo todo "Doesn't extend lists ending in , * yet"
694 @r = <A B C D E> »~» (1, 2, 3, *);
695 @e = <A1 B2 C3 D3 E3>;
696 is ~@r, ~@e, 'dwimmy hyper extends lists ending with * by copying the last element';