my $schema = DBICTest->init_schema();
-plan tests => 17;
+plan tests => 19;
# Test ensure_class_found
ok( $schema->ensure_class_found('DBIx::Class::Schema'),
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' );
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->ensure_class_loaded('DBICTest::SyntaxErrorComponent1') };
+ like( $@, qr/syntax error/,
+ 'ensure_class_loaded(DBICTest::SyntaxErrorComponent1) threw ok' );
+ eval { $schema->load_optional_class('DBICTest::SyntaxErrorComponent2') };
+ like( $@, qr/syntax error/,
+ 'load_optional_class(DBICTest::SyntaxErrorComponent2) threw ok' );
+}
+
1;