Skip to content

Commit

Permalink
Test error for optional params marked 'is rw'
Browse files Browse the repository at this point in the history
These were copied from t/spec/S06-signature/optional.t and modified to
test the new error message, including that the name of the parameter is
in the message. The tests in t/spec/S06-signature/optional.t will be
modified to just test that an exception is thrown (and possibly its
type), not the text of the message.
  • Loading branch information
MasterDuke17 committed Apr 14, 2017
1 parent c2fa77f commit 135ddee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions t/05-messages/01-errors.t
Expand Up @@ -49,4 +49,17 @@ throws-like 「m: my @a = for 1..3 <-> { $_ }」, Exception,
:message(/«'do for'»/),
'<-> does not prevent an error suggesting to use `do for`';

# https://irclog.perlgeek.de/perl6-dev/2017-04-13#i_14425133
# RT #79288
{
my $param = '$bar';
throws-like { EVAL q[ sub foo(\qq{$param}? is rw) {} ] }, Exception,
message => "Cannot use 'is rw' on optional parameter '$param'",
'making an "is rw" parameter optional dies with adequate error message and mentions the parameter name';

throws-like { EVAL q[ sub foo(\qq{$param} is rw = 42) {} ] }, Exception,
message => "Cannot use 'is rw' on optional parameter '$param'",
'making an "is rw" parameter optional dies with adequate error message and mentions the parameter name';
}

done-testing;

0 comments on commit 135ddee

Please sign in to comment.