check result of eval operation rather than looking at $@
[p5sagit/Devel-REPL.git] / t / load_plugins.t
index abed39f..891a72c 100755 (executable)
@@ -1,10 +1,9 @@
+
 use strict;
 use warnings;
 
-use FindBin qw($Bin);
-use lib "$Bin/../t/lib";
-
-use Test::More 'no_plan';
+use Test::More;
+use Test::Warnings;
 
 use_ok('Devel::REPL');
 
@@ -40,23 +39,28 @@ Timing
 Turtles
 /;
 
+# one $repl is shared:
+# "Looks like the problem is that you can't open multiple instances of
+# Term::ReadLine:Perl from the same object.  I was able to correct this by
+# changing the test to reuse the same Devel::REPL instance each time.  This
+# prevents the warning that causes the test to fail.  I don't think this
+# changes the spirit of the test, it's just a byproduct of how
+# Term::ReadLine::Perl works." -- RT#84246
+my $repl = Devel::REPL->new;
 for my $plugin_name (@plugins) {
     test_load_plugin($plugin_name);
 }
 
 sub test_load_plugin {
     my ($plugin_name) = @_;
-    my $repl = Devel::REPL->new;
     my $test_name = "plugin $plugin_name loaded";
-    eval "use Devel::REPL::Plugin::$plugin_name";
-    unless($@) {
-        eval { $repl->load_plugin($plugin_name) };
-        ok(!$@, $test_name);
-    } else {
-        SKIP: {
-                skip "could not eval plugin $plugin_name", 1;
-        }
+
+    SKIP: {
+        eval "use Devel::REPL::Plugin::$plugin_name; 1"
+            or skip "could not eval plugin $plugin_name", 1;
+
+        ok(eval { $repl->load_plugin($plugin_name); 1 }, $test_name);
     }
 }
 
-1;
+done_testing;