Permalink
Browse files

Add test for RT#49072 (catch without a var name)

  • Loading branch information...
1 parent 11d4dcf commit 172fdb9167bcd01a4ae225b5ed88cc80a64cc6fd @ashb committed Sep 7, 2009
Showing with 31 additions and 4 deletions.
  1. +6 −4 lib/TryCatch.pm
  2. +16 −0 t/lib/NoVarName.pm
  3. +9 −0 t/types.t
View
@@ -298,11 +298,13 @@ sub parse_proto_using_pms {
my $left = $sig->remaining_input;
- croak "TryCatch can't handle un-named vars in catch signature"
- unless $param->can('variable_name');
+ my $var_code = '';
- my $name = $param->variable_name;
- my $var_code = "my $name = \$TryCatch::Error;";
+ if (my $var_name = $param->can('variable_name') ) {
+
+ my $name = $param->$var_name();
+ $var_code = "my $name = \$TryCatch::Error;";
+ }
# (TC $var)
if ($param->has_type_constraints) {
View
@@ -0,0 +1,16 @@
+package NoVarName;
+
+use strict;
+use warnings;
+
+#use Moose;
+use TryCatch;
+
+try {
+}
+catch(Error $) {
+ print "Error catched\n";
+}
+
+1;
+
View
@@ -16,5 +16,14 @@ catch ($e) {
diag($e);
}
+try {
+ require NoVarName;
+ pass("Types can be declared without a var name");
+}
+catch ($e) {
+ fail("Types can be declared without a var name");
+ diag($e);
+}
+
done_testing;

0 comments on commit 172fdb9

Please sign in to comment.