httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject expect_ok sub?
Date Fri, 31 Aug 2001 07:12:23 GMT

Many times we create subtests like this:

print comment
my $expect = ...
my $got    = ...
print expect
print got
ok $expect eq $got

and end up with lots of typing. I suggest expect_ok, or just eok():

sub expect_ok{
    my ($expect,$received,$comment) = @_;
    print "$comment\n" if defined $comment;
    print "expected: $expect\n";
    print "received: $received\n";
    ok($expect eq $received);
}

so for example here is a test from alias.t shrink-wrapped:

## with ScriptAliasMatch ##
eok(
   $string,
   GET_BODY("/aliascgi-script"),
   "verifying ScriptAliasMatch with /aliascgi-script",
   );

I think using 'eq' is safe enough for numerical and string comparisons. or
we could make e_num_ok and e_str_ok to use '==' and 'eq' respectively.

some people write tests without printing expect/received strings and when
the test fail, users have to go and do it themselves. Such a wrapper does
this job for the test writers for free.

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://localhost/      http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Mime
View raw message