Skip to content

Commit d09d566

Browse files
committed
Add tests for Niecza #49
1 parent 698a5e1 commit d09d566

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

S06-signature/optional.t

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use Test;
33

44
# L<S06/Optional parameters/>
55

6-
plan 16;
6+
plan 20;
77

88
sub opt1($p?) { defined($p) ?? $p !! 'undef'; }
99

@@ -70,6 +70,16 @@ dies_ok {foo_53814(1,Mu,'something_extra',:y(3))},
7070
eval_dies_ok( 'sub rt66822($opt?, $req) { "$opt, $req" }',
7171
"Can't put required parameter after optional parameters" );
7272

73+
# Niecza bug#49
74+
sub opt_array1(@x?) { @x.elems }
75+
sub opt_array2(@x? is copy) { @x.elems }
76+
sub opt_hash1(%x?) { %x.keys.elems }
77+
sub opt_hash2(%x? is copy) { %x.keys.elems }
78+
is opt_array1(), 0, "optional array not passed is empty";
79+
is opt_array2(), 0, "optional array not passed is empty (copy)";
80+
is opt_hash1(), 0, "optional hash not passed is empty";
81+
is opt_hash2(), 0, "optional hash not passed is empty (copy)";
82+
7383
done;
74-
84+
7585
# vim: ft=perl6

0 commit comments

Comments
 (0)