Bumping version to 5.90123
[catagits/Catalyst-Runtime.git] / t / unit_utils_load_class.t
index d23ca1c..c2535d2 100644 (file)
@@ -1,14 +1,17 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 
-use Test::More tests => 16;
-use Class::MOP;
-
+use Test::More;
+use Class::Load 'is_class_loaded';
 use lib "t/lib";
 
-BEGIN { use_ok("Catalyst::Utils") };
+BEGIN {
+  if ($^O =~ m/^MSWin/) {
+    plan skip_all => 'Skipping this test on Windows until someone with Windows has time to fix it';
+  }
+
+  use_ok("Catalyst::Utils");
+}
 
 {
     package This::Module::Is::Not::In::Inc::But::Does::Exist;
@@ -16,13 +19,16 @@ BEGIN { use_ok("Catalyst::Utils") };
 }
 
 my $warnings = 0;
-$SIG{__WARN__} = sub { $warnings++ };
+$SIG{__WARN__} = sub {
+    return if $_[0] =~ /Subroutine (?:un|re|)initialize redefined at .*C3\.pm/;
+    $warnings++;
+};
 
-ok( !Class::MOP::is_class_loaded("TestApp::View::Dump"), "component not yet loaded" );
+ok( !is_class_loaded("TestApp::View::Dump"), "component not yet loaded" );
 
 Catalyst::Utils::ensure_class_loaded("TestApp::View::Dump");
 
-ok( Class::MOP::is_class_loaded("TestApp::View::Dump"), "loaded ok" );
+ok( is_class_loaded("TestApp::View::Dump"), "loaded ok" );
 is( $warnings, 0, "no warnings emitted" );
 
 $warnings = 0;
@@ -30,10 +36,10 @@ $warnings = 0;
 Catalyst::Utils::ensure_class_loaded("TestApp::View::Dump");
 is( $warnings, 0, "calling again doesn't reaload" );
 
-ok( !Class::MOP::is_class_loaded("TestApp::View::Dump::Request"), "component not yet loaded" );
+ok( !is_class_loaded("TestApp::View::Dump::Request"), "component not yet loaded" );
 
 Catalyst::Utils::ensure_class_loaded("TestApp::View::Dump::Request");
-ok( Class::MOP::is_class_loaded("TestApp::View::Dump::Request"), "loaded ok" );
+ok( is_class_loaded("TestApp::View::Dump::Request"), "loaded ok" );
 
 is( $warnings, 0, "calling again doesn't reaload" );
 
@@ -53,7 +59,7 @@ is( $@, "foo", '$@ is untouched' );
 
 undef $@;
 eval { Catalyst::Utils::ensure_class_loaded("This::Module::Is::Not::In::Inc::But::Does::Exist") };
-ok( !$@, "no error when loading non existent .pm that *does* have a symbol table entry" ); 
+ok( !$@, "no error when loading non existent .pm that *does* have a symbol table entry" );
 
 undef $@;
 eval { Catalyst::Utils::ensure_class_loaded('Silly::File::.#Name') };
@@ -63,3 +69,10 @@ undef $@;
 eval { Catalyst::Utils::ensure_class_loaded('Silly::File::Name.pm') };
 like($@, qr/Malformed class Name/, 'errored sanely when given a classname ending in .pm');
 
+undef $@;
+$warnings = 0;
+Catalyst::Utils::ensure_class_loaded("NullPackage");
+is( $warnings, 1, 'Loading a package which defines no symbols warns');
+is( $@, undef, '$@ still undef' );
+
+done_testing;