Skip to content

Commit fcfe955

Browse files
committed
test for unpacking objects in signatures
1 parent bcb1a97 commit fcfe955

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

S06-signature/unpack-object.t

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use v6;
2+
use Test;
3+
plan 2;
4+
5+
{
6+
my $tracker = '';
7+
for a => 1, b => 2 -> Pair $p (:$key, :$value) {
8+
$tracker ~= "|$key,$value";
9+
}
10+
is $tracker, '|a,1|b,2', 'unpacking a Pair';
11+
}
12+
13+
{
14+
class A { has $.x };
15+
16+
my $tracker = '';
17+
for A.new(x => 4), A.new(x => 2) -> $ (:$x) {
18+
$tracker ~= $x;
19+
}
20+
is $tracker, '42', 'unpacking attribute of custom class';
21+
}

0 commit comments

Comments
 (0)