Browse Source

autotest: use ints where we mean ints

... instead of using strings. perl allows being sloppy, but it doesn't
really help understanding the code.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
325551ce79
  1. 12
      src/run-tests.pl

12
src/run-tests.pl

@ -441,7 +441,7 @@ sub readbox($)
for my $f (grep(!/^\.\.?$/, readdir(DIR))) { for my $f (grep(!/^\.\.?$/, readdir(DIR))) {
my ($uid, $flg, $ph, $num); my ($uid, $flg, $ph, $num);
if ($f =~ /^\d+\.\d+_\d+\.[-[:alnum:]]+,U=(\d+):2,(.*)$/) { if ($f =~ /^\d+\.\d+_\d+\.[-[:alnum:]]+,U=(\d+):2,(.*)$/) {
($uid, $flg) = ($1, $2); ($uid, $flg) = (int($1), $2);
} else { } else {
print STDERR "unrecognided file name '$f' in '$bn'.\n"; print STDERR "unrecognided file name '$f' in '$bn'.\n";
exit 1; exit 1;
@ -449,7 +449,7 @@ sub readbox($)
open(FILE, "<", $bn."/".$d."/".$f) or die "Cannot read message '$f' in '$bn'.\n"; open(FILE, "<", $bn."/".$d."/".$f) or die "Cannot read message '$f' in '$bn'.\n";
my $sz = 0; my $sz = 0;
while (<FILE>) { while (<FILE>) {
/^Subject: (\[placeholder\] )?(\d+)$/ && ($ph = defined($1), $num = $2); /^Subject: (\[placeholder\] )?(\d+)$/ && ($ph = defined($1), $num = int($2));
$sz += length($_); $sz += length($_);
} }
close FILE; close FILE;
@ -501,7 +501,7 @@ sub readstate($)
print STDERR "Unexpected sync state header entry: $1\n"; print STDERR "Unexpected sync state header entry: $1\n";
return; return;
} }
$$want = $2; $$want = int($2);
} }
print STDERR "Unterminated sync state header.\n"; print STDERR "Unterminated sync state header.\n";
return; return;
@ -521,7 +521,7 @@ sub readstate($)
print STDERR "Malformed sync state entry: $_\n"; print STDERR "Malformed sync state entry: $_\n";
return; return;
} }
push @ents, [ $1, $2, $3 ]; push @ents, [ int($1), int($2), $3 ];
} }
return \%ss; return \%ss;
} }
@ -649,7 +649,7 @@ sub ckbox($$)
print STDERR "No message $bn:$uid.\n"; print STDERR "No message $bn:$uid.\n";
return 1; return 1;
} }
if ($$m[0] ne $num) { if ($$m[0] != $num) {
print STDERR "Subject mismatch for $bn:$uid.\n"; print STDERR "Subject mismatch for $bn:$uid.\n";
return 1; return 1;
} }
@ -677,7 +677,7 @@ sub ckstate($$)
['MaxPushedUid', 'max_pushed']) { ['MaxPushedUid', 'max_pushed']) {
my ($hn, $sn) = @$h; my ($hn, $sn) = @$h;
my ($got, $want) = ($$ss{$sn}, $$ref_ss{$sn}); my ($got, $want) = ($$ss{$sn}, $$ref_ss{$sn});
if ($got ne $want) { if ($got != $want) {
print STDERR "Sync state header entry $hn mismatch: got $got, wanted $want\n"; print STDERR "Sync state header entry $hn mismatch: got $got, wanted $want\n";
return 1; return 1;
} }

Loading…
Cancel
Save