Skip Menu |
 

This queue is for tickets about the Class-C3-Componentised CPAN distribution.

Report information
The Basics
Id: 56565
Status: resolved
Priority: 0/
Queue: Class-C3-Componentised

People
Owner: Nobody in particular
Requestors: POSSUM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.0006
Fixed in: 1.0008

Attachments
class_c3_componentised_ends_with_colon.patch



Subject: [PATCH] load_optional_class can't handle a trailing :: (Includes test)
Download (untitled) / with headers
text/plain 506b
According to the documentation, load_optional_class should return 0 if the requested class is not found. There is a bug when determining the filename to compare against the exception thrown for the failed class. This evidences itself when looking for a class name ending with a double colon; i.e., "Class::Name::" will throw an exception because it will look for the string "Class/Name.pm" instead of "Class/Name/.pm". The attached patch (against 1.0006) consists of a test case and a solution for this.
Subject: class_c3_componentised_ends_with_colon.patch
diff -Naur Class-C3-Componentised-1.0006/lib/Class/C3/Componentised.pm Class-C3-Componentised-1.0006/lib/Class/C3/Componentised.pm --- Class-C3-Componentised-1.0006/lib/Class/C3/Componentised.pm 2009-09-08 09:14:12.000000000 -0400 +++ Class-C3-Componentised-1.0006/lib/Class/C3/Componentised.pm 2010-04-13 12:11:29.000000000 -0400 @@ -196,7 +196,7 @@ return 1; } else { - my $fn = (join ('/', split ('::', $f_class) ) ) . '.pm'; + ( my $fn = $f_class . '.pm' ) =~ s/::/\//g; if ($err =~ /Can't locate ${fn} in \@INC/ ) { return 0; } diff -Naur Class-C3-Componentised-1.0006/t/01-basic.t Class-C3-Componentised-1.0006/t/01-basic.t --- Class-C3-Componentised-1.0006/t/01-basic.t 2009-09-08 09:07:32.000000000 -0400 +++ Class-C3-Componentised-1.0006/t/01-basic.t 2010-04-13 12:11:44.000000000 -0400 @@ -8,7 +8,7 @@ use lib "$FindBin::Bin/lib"; -plan tests => 22; +plan tests => 24; BEGIN { package TestPackage::A; @@ -52,6 +52,10 @@ like( $@, qr/did not return a true value/, 'MyModule::ErrorComponent threw ok' ); +$retval = eval { MyModule->load_optional_class('ENDS::WITH::COLONS::') }; +ok( !$@, 'load_optional_class did not throw' ) || diag $@; +ok( !$retval, "No such class ENDS::WITH::COLONS::" ); + # Simulate a PAR environment { my @code;
Download (untitled) / with headers
text/plain 465b
On Tue Apr 13 12:34:38 2010, POSSUM wrote: Show quoted text
> According to the documentation, load_optional_class should return 0 if > the requested class is not found.
But it does not really define what to do with invalid class names (something that could not possibly be found). After consultation with the original authors it was decided to keep the exception but make it explicit "this classname is bork". http://dev.catalystframework.org/svnweb/bast/revision?rev=9834 Cheers


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.