[Catalyst] html-widget test prereq
Carl Franks
fireartist at gmail.com
Mon Mar 13 12:16:46 CET 2006
In the html-widget test suite, instead of having this copy-pasted in many files,
my $query = Test::MockObject->new;
my $data = { foo => 'foo', bar => [ 'yada', 23 ] };
$query->mock( 'param',
sub {
my ( $self, $param ) = @_;
if ( @_ == 1 ) { return keys %$data }
else {
unless ( exists $data->{$param} ) {
return wantarray ? () : undef;
}
if ( ref $data->{$param} eq 'ARRAY' ) {
return (wantarray)
? @{ $data->{$param} }
: $data->{$param}->[0];
}
else {
return (wantarray)
? ( $data->{$param} )
: $data->{$param};
}
}
}
);
Considering CGI.pm has been a core module since perl 5.004, how about
we just do this instead?
my $query = CGI->new;
$query->param( foo => 'foo' );
$query->param( bar => [ 'yada', 23 ] );
I can imagine "minimal dependencies in test suite" being a reasonable
objection, but I'm sure CGI's param() method is generally better
tested than the code currently used.
Personally, I'd find it easier to read the test files with the 2nd example.
(I am offering to do the chore myself, of course!)
Cheers,
Carl
More information about the Catalyst
mailing list