Skip to content

Commit 53d2c03

Browse files
committed
Correct a bunch of wrong assumptions about \ capture former.
1 parent a8b638a commit 53d2c03

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

S02-literals/autoref.t

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ plan 57;
3333

3434
is ~$ref, "a b c", '$arrayref = \@array works (1)';
3535
# Explicit referentiation of arrays in assignment
36-
is +$ref, 3, '$arrayref = \@array works (2)';
36+
is +$ref, 1, '$arrayref = \@array works (2)';
3737
}
3838

3939
# Implicit referentiation of hashes in assignment
@@ -50,9 +50,8 @@ plan 57;
5050
my %hash = (a => 1, b => 2, c => 3);
5151
my $ref = \%hash;
5252

53-
#?rakudo todo 'backslashes, captures'
54-
is ~$ref.values.sort, "1 2 3", '$hashref = \%hash works (1)';
55-
is +$ref.values, 3, '$hashref = \%hash works (2)';
53+
is ~$ref[0].values.sort, "1 2 3", '$hashref = \%hash works (1)';
54+
is +$ref[0].values, 3, '$hashref = \%hash works (2)';
5655
}
5756

5857
# Implicit referentiation of arrays in assignment to an array element
@@ -74,7 +73,7 @@ plan 57;
7473

7574
is ~@other, " a b c", '@other[$idx] = \@array works (1)';
7675
is +@other, 2, '@other[$idx] = \@array works (2)';
77-
is +@other[1], 3, '@other[$idx] = \@array works (3)';
76+
is +@other[1], 1, '@other[$idx] = \@array works (3)';
7877
}
7978

8079
# Implicit referentiation of hashes in assignment to an array element
@@ -94,7 +93,7 @@ plan 57;
9493
@other[1] = \%hash;
9594

9695
is +@other, 2, '@other[$idx] = \%hash works (1)';
97-
is +@other[1], 3, '@other[$idx] = \%hash works (2)';
96+
is +@other[1], 1, '@other[$idx] = \%hash works (2)';
9897
}
9998

10099
# Implicit referentiation of arrays in assignment to a hash element
@@ -114,7 +113,7 @@ plan 57;
114113
%other<a> = \@array;
115114

116115
is +%other, 1, '%other[$key] = \@array works (1)';
117-
is +%other<a>, 3, '%other[$key] = \@array works (2)';
116+
is +%other<a>, 1, '%other[$key] = \@array works (2)';
118117
}
119118

120119
# Implicit referentiation of hashes in assignment to a hash element
@@ -134,7 +133,7 @@ plan 57;
134133
%other<a> = \%hash;
135134

136135
is +%other, 1, '%other[$key] = \%hash works (1)';
137-
is +%other<a>, 3, '%other[$key] = \%hash works (2)';
136+
is +%other<a>, 1, '%other[$key] = \%hash works (2)';
138137
}
139138

140139
# Implicit referentiation of arrays in pair creation with key => ...
@@ -152,7 +151,7 @@ plan 57;
152151
my $pair = (key => \@array);
153152

154153
is ~$pair.value, "a b c", '(key => \@array) works (1)';
155-
is +$pair.value, 3, '(key => \@array) works (2)';
154+
is +$pair.value, 1, '(key => \@array) works (2)';
156155
}
157156

158157
# Implicit referentiation of hashes in pair creation with key => ...
@@ -169,9 +168,8 @@ plan 57;
169168
my %hash = (a => 1, b => 2, c => 3);
170169
my $pair = (key => \%hash);
171170

172-
#?rakudo todo 'backslashes, captures'
173-
is ~$pair.value.values.sort, "1 2 3", '(key => \%hash) works (1)';
174-
is +$pair.value.values, 3, '(key => \%hash) works (2)';
171+
is ~$pair.value.[0].values.sort, "1 2 3", '(key => \%hash) works (1)';
172+
is +$pair.value.[0].values, 3, '(key => \%hash) works (2)';
175173
}
176174

177175
# Implicit referentiation of arrays in pair creation with :key(...)
@@ -189,7 +187,7 @@ plan 57;
189187
my $pair = (:key(\@array));
190188

191189
is ~$pair.value, "a b c", '(:key(\@array)) works (1)';
192-
is +$pair.value, 3, '(:key(\@array)) works (2)';
190+
is +$pair.value, 1, '(:key(\@array)) works (2)';
193191
}
194192

195193
# Implicit referentiation of hashes in pair creation with :key(...)
@@ -207,8 +205,8 @@ plan 57;
207205
my $pair = (:key(\%hash));
208206

209207
#?rakudo todo 'backslashes, captures'
210-
is ~$pair.value.values.sort, "1 2 3", '(:key(\%hash)) works (1)';
211-
is +$pair.value.values, 3, '(:key(\%hash)) works (2)';
208+
is ~$pair.value.[0].values.sort, "1 2 3", '(:key(\%hash)) works (1)';
209+
is +$pair.value.[0].values, 3, '(:key(\%hash)) works (2)';
212210
}
213211

214212
# Implicit referentiation of array literals in pair creation with key => ...

0 commit comments

Comments
 (0)