stas 2004/08/06 19:14:11
Modified: perl-framework/Apache-Test/lib/Apache Test.pm
Log:
further polish of have_ => need_ transition: the main problem solved is
localizing $_ on behalf of users calls have_foo($_) in the for loop (which
didn't work because $_ gets trashed on the way), while doing that dropped
AUTOLOAD.
Revision Changes Path
1.93 +15 -16 httpd-test/perl-framework/Apache-Test/lib/Apache/Test.pm
Index: Test.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/Test.pm,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -u -r1.92 -r1.93
--- Test.pm 6 Aug 2004 21:43:22 -0000 1.92
+++ Test.pm 7 Aug 2004 02:14:11 -0000 1.93
@@ -29,7 +29,7 @@
need_module need_apache need_min_apache_version
need_apache_version need_perl need_min_perl_version
need_min_module_version need_threads need_apache_mpm
- need_php);
+ need_php need_ssl);
my @have = map { (my $need = $_) =~ s/need/have/; $need } @need;
@@ -207,7 +207,9 @@
sub need_module {
my $cfg = config();
- my @modules = ref($_[0]) ? @{ $_[0] } : @_;
+
+ my @modules = grep defined $_,
+ ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_;
my @reasons = ();
for (@modules) {
@@ -422,21 +424,18 @@
return join '', map { sprintf("%03d", $_ || 0) } @digits;
}
-sub AUTOLOAD {
-
- (my $method) = $AUTOLOAD =~ m/.*::(.*)/;
-
- return unless $method =~ m/^have_/;
-
- $method =~ s/^have/need/;
-
- if (my $cv = Apache::Test->can($method)) {
+# have_ functions are the same as need_ but they don't populate
+# @SkipReasons
+for my $func (@have) {
+ no strict 'refs';
+ (my $real_func = $func) =~ s/^have_/need_/;
+ *$func = sub {
+ # be nice to poor soles calling functions with $_ argument in
+ # the foreach loop, etc.!
+ local $_;
local @SkipReasons;
- return $cv->(@_);
- }
- else {
- die "could not find function $AUTOLOAD";
- }
+ return $real_func->(@_);
+ };
}
package Apache::TestToString;