X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F90ensure_class_loaded.t;h=4da8a75075492b7831587749c0a06ca76abf9de4;hb=175e261686dfde702e3539a47707024260c877b2;hp=672450b1af0a0b79cd5cde2c0696fc863474915a;hpb=92315142a9728b4b23fff646a95a5732c687a645;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/90ensure_class_loaded.t b/t/90ensure_class_loaded.t index 672450b..4da8a75 100644 --- a/t/90ensure_class_loaded.t +++ b/t/90ensure_class_loaded.t @@ -13,7 +13,7 @@ BEGIN { my $schema = DBICTest->init_schema(); -plan tests => 17; +plan tests => 19; # Test ensure_class_found ok( $schema->ensure_class_found('DBIx::Class::Schema'), @@ -37,7 +37,8 @@ $retval = eval { $schema->load_optional_class('DBICTest::OptionalComponent') }; ok( !$@, 'load_optional_class on an existing class did not throw' ); ok( $retval, 'DBICTest::OptionalComponent loaded' ); eval { $schema->load_optional_class('DBICTest::ErrorComponent') }; -like( $@, qr/did not return a true value/, 'DBICTest::ErrorComponent threw ok' ); +like( $@, qr/did not return a true value/, + 'DBICTest::ErrorComponent threw ok' ); # Test ensure_class_loaded ok( Class::Inspector->loaded('TestPackage::A'), 'anonymous package exists' ); @@ -53,4 +54,19 @@ ok( !$@, 'ensure_class_loaded detected an existing but non-loaded class' ); ok( Class::Inspector->loaded('DBICTest::FakeComponent'), 'DBICTest::FakeComponent now loaded' ); +{ + # Squash warnings about syntax errors in SytaxErrorComponent.pm + local $SIG{__WARN__} = sub { + my $warning = shift; + warn $warning unless ( + $warning =~ /String found where operator expected/ or + $warning =~ /Missing operator before/ + ); + }; + eval { $schema->load_optional_class('DBICTest::SyntaxErrorComponent') }; + like( $@, qr/syntax error/, 'DBICTest::ErrorComponent threw ok' ); + eval { $schema->ensure_class_loaded('DBICTest::SyntaxErrorComponent') }; + like( $@, qr/syntax error/, 'DBICTest::ErrorComponent threw ok' ); +} + 1;