Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed 99f56ce

- fixed http://rt.cpan.org/Public/Bug/Display.html?id=20643 by applying
a modified version of the patch by MAREKR with the t/12wrong-error-var.t
regression test.

  • Participants
  • Parent commits c93a898

Comments (0)

Files changed (4)

File module/ChangeLog

+Aug 28 2007 <shlomif@iglu.org.il> (Shlomi Fish)
+
+  Error.pm #0.17009
+  - fixed http://rt.cpan.org/Public/Bug/Display.html?id=20643 by applying
+  a modified version of the patch by MAREKR with the t/12wrong-error-var.t
+  regression test.
+
 Oct 25 2006 <shlomif@iglu.org.il> (Shlomi Fish)
 
   Error.pm #0.17008

File module/MANIFEST

 t/09dollar-at.t
 t/10throw-in-catch.t
 t/11rethrow.t
+t/12wrong-error-var.t
 t/lib/MyDie.pm
 t/pod-coverage.t
 t/pod.t

File module/lib/Error.pm

 use vars qw($VERSION);
 use 5.004;
 
-$VERSION = "0.17008"; 
+$VERSION = "0.17008_01"; 
 
 use overload (
 	'""'	   =>	'stringify',
 			    undef $err;
 			}
 			else {
-			    $err = defined($Error::THROWN)
-				    ? $Error::THROWN : $@;
+			    $err = $@ || $Error::THROWN;
 				$err = $Error::ObjectifyCallback->({'text' =>$err})
 					unless ref($err);
 			}
 		undef $err;
 	    }
 	    else {
-		$err = defined($Error::THROWN)
-			? $Error::THROWN : $@;
+		$err = $@ || $Error::THROWN;
 
 		$err = $Error::ObjectifyCallback->({'text' =>$err}) 
 			unless ref($err);
 	    1;
 	};
 
-	$err = defined($Error::THROWN) ? $Error::THROWN : $@
+	$err = $@ || $Error::THROWN
 	    unless $ok;
     };
 

File module/t/12wrong-error-var.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Error qw(:try);
+
+try {
+  eval {
+   throw Error::Simple "This is caught by eval, not by try.";
+  };
+
+  # TEST
+  ok (($@ && $@ =~ /This is caught by eval, not by try/),
+      "Checking that eval { ... } is sane"
+     );
+
+  print "# Error::THROWN = $Error::THROWN\n";
+
+  die "This is a simple 'die' exception.";
+
+  # not reached
+}
+otherwise {
+  my $E = shift;
+  my $t = $Error::THROWN ? "$Error::THROWN" : '';
+  print "# Error::THROWN = $t\n";
+  $E ||= '';
+  print "# E = $E\n";
+
+  # TEST
+  ok ("$E" =~ /This is a simple 'die' exception/,
+      "Checking that the argument to otherwise is the thrown exception"
+  );
+};