Re: t/modules/expires.t .. expected?

2001-10-17 Thread Rodent of Unusual Size
Rodent of Unusual Size wrote:
 
 expires_test() fails at the end if $actual != $expected.  So
 I don't quite get how the first if-block sets expected
 correctly:

Never mind, I'm an idiot.
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

All right everyone!  Step away from the glowing hamburger!


t/modules/expires.t .. expected?

2001-10-16 Thread Rodent of Unusual Size
H',m.  In trying to figure out why modules/expires tests
13, 21, and 33 are failing on Apache 1.3.22-dev, and in my
first fumblings with the perl-framework, I poked into
expires.t.

expires_test() fails at the end if $actual != $expected.  So
I don't quite get how the first if-block sets expected
correctly:

my $expected = '';
my $exp_type = '';
if ($exp_conf =~ /^([A|M])(\d+)$/) {
$exp_type = $1;
$expected = $2;
} else {
print STDERR \n\ndoom: $exp_conf\n\n;
return 0;
}

my $actual = 0;
if ($exp_type eq 'M') {
$actual = $headers{expires} - $headers{modified};
} elsif ($exp_type eq 'A') {
$actual = $headers{expires} - $headers{access};
}

print debug: expected: $expected\n;
print debug: actual  : $actual\n;
return ($actual == $expected);

I would think it would need to include

if ($exp_type eq 'A') {
$expected += $headers{access};
} else {
$expected += $headers{modified};
}

but that breaks many more tests (although 13, 22, and 33
pass ;-).
-- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

All right everyone!  Step away from the glowing hamburger!


Re: t/modules/expires.t .. expected?

2001-10-16 Thread john sachs
hi,

On Tue, Oct 16, 2001 at 05:46:25PM -0400, Rodent of Unusual Size wrote:

+ expires_test() fails at the end if $actual != $expected.  So
+ I don't quite get how the first if-block sets expected
+ correctly:
+ 
+ my $expected = '';
+ my $exp_type = '';
+ if ($exp_conf =~ /^([A|M])(\d+)$/) {
+ $exp_type = $1;
+ $expected = $2;
+ } else {
+ print STDERR \n\ndoom: $exp_conf\n\n;
+ return 0;
+ }
+ 
+ my $actual = 0;
+ if ($exp_type eq 'M') {
+ $actual = $headers{expires} - $headers{modified};
+ } elsif ($exp_type eq 'A') {
+ $actual = $headers{expires} - $headers{access};
+ }
+ 
+ print debug: expected: $expected\n;
+ print debug: actual  : $actual\n;
+ return ($actual == $expected);
+ 
+ I would think it would need to include
+ 
+ if ($exp_type eq 'A') {
+ $expected += $headers{access};
+ } else {
+ $expected += $headers{modified};
+ }

why?
expected is being set to whatever is in the config.
so if the config is A120, expected is 120 seconds.  so the difference between 
the acce3ss header and the expires header should be 120 seconds.

 } elsif ($exp_type eq 'A') {
 $actual = $headers{expires} - $headers{access};

at that point $actual should be 120 if everything went smoothly.  your expected 
is already set to 120 from

 if ($exp_conf =~ /^([A|M])(\d+)$/) {
 $exp_type = $1;
 $expected = $2;

if you did

 if ($exp_type eq 'A') {
 $expected += $headers{access};

$expected would be some wacky number (120 + whatever the access time was).
so i dont see how those three tests pass with that code added...

run t/TEST -v t/modules/expires.t
and paste the relevant debug output into a mail and i'll take a look...

-j