Mail-Digest-Tools
view release on metacpan or search on metacpan
@pw32u_tp = sort {lc($a) cmp lc($b)} (
'Net::SSH::Perl.thr.txt',
'Perl and delphi interaction query.thr.txt',
'qx broken on Win98.thr.txt',
);
} elsif ($^O eq 'MSWin32') {
@pw32u_tp = sort {lc($a) cmp lc($b)} (
'NetSSHPerl.thr.txt',
'Perl and delphi interaction query.thr.txt',
'qx broken on Win98.thr.txt',
);
} else {
die "Mail::Digest::Tools not available for operating system $^O: $!";
}
ok(@pw32u_tp == 3, 'Predict 3 threads from pw32u');# 2
# 0th element in value: by observation, predict number of messages in
# each thread file created
# 1st element in value: by observation, predict number of paragraphs in each
# message in each thread file created
my %pw32u_tp = (
$pw32u_tp[0] => [ 7, [ 10, 6, 5, 6, 6, 4, 10 ] ],
$pw32u_tp[1] => [ 4, [ 12, 6, 6, 6 ] ],
$pw32u_tp[2] => [ 6, [ 8, 6, 5, 6, 8, 8 ] ],
);
# predict message numbers found within each thread file created
# (by observation)
my %pw32u_messp = (
$pw32u_tp[0] => [ qw|
001_0001_0001
001_0002_0001
001_0002_0003
001_0002_0004
001_0002_0005
001_0002_0006
001_0002_0013
| ],
$pw32u_tp[1] => [ qw|
001_0001_0002
001_0001_0003
001_0002_0002
001_0002_0014
| ],
$pw32u_tp[2] => [ qw|
001_0002_0007
001_0002_0008
001_0002_0009
001_0002_0010
001_0002_0011
001_0002_0012
| ],
);
# determine number of digests needing processing
opendir DIG, $pw32u_digdir or die "Couldn't open directory $pw32u_digdir: $!";
$log{'digs'} = scalar(
grep { /$pw32u_config_in{'grep_formula'}/ } readdir DIG);
closedir DIG or die "Couldn't close directory $pw32u_digdir: $!";
ok($log{'digs'} == 2, '2 pw32u digests found before processing'); # 3
# verify log files are empty or do not yet exist
my $dl = $pw32u_config_out{'digests_log'};
my $dr = $pw32u_config_out{'digests_read'};
my $drf = $pw32u_config_out{'digests_read_flag'};
my $tt = $pw32u_config_out{'todays_topics'};
$log{'log'}{'size'}[0] = (-f $dl) ? (-s $dl) : 0;
$log{'read'}{'size'}[0] = ( (-f $dr) and $drf) ? (-s $dr) : undef;
$log{'topics'}{'size'}[0] = (-f $tt) ? (-s $tt) : 0;
$log{'log'}{'records'}[0] = (-f $dl) ? count_records($dl, "\n") : 0;
$log{'read'}{'records'}[0] = ((-f $dr) and $drf) ? count_records($dr, "\n\n") : 0;
$log{'topics'}{'records'}[0] = (-f $tt) ? count_records($tt, "\n\n") : 0;
ok($log{'log'}{'records'}[0] == 0, 'digests_log currently empty'); # 4
ok($log{'read'}{'records'}[0] == 0, 'digests_read currently empty'); # 5
ok($log{'topics'}{'records'}[0] == 0, 'todays_topics currently empty'); # 6
# run Mail::Digest::tools function
process_new_digests(\%pw32u_config_in, \%pw32u_config_out);
# test whether log files have grown in size
$log{'log'}{'size'}[1] = (-s $dl);
$log{'read'}{'size'}[1] = ( (-f $dr) and $drf) ? (-s $dr) : undef;
$log{'topics'}{'size'}[1] = (-s $tt);
ok($log{'log'}{'size'}[1] > $log{'log'}{'size'}[0]);# 7
ok( # 8
(
(
! defined $log{'read'}{'size'}[0]
and
! defined $log{'read'}{'size'}[1]
)
or
(
(
defined $log{'read'}{'size'}[0]
and
defined $log{'read'}{'size'}[1]
)
and
(
$log{'read'}{'size'}[1] > $log{'read'}{'size'}[0]
)
)
), 'digests read for pw32u has grown'
);
ok($log{'topics'}{'size'}[1] > $log{'topics'}{'size'}[0],# 9
'todays topics for pw32u has grown');
# test whether log files have grown by correct number of records
$log{'log'}{'records'}[1] = (-f $dl) ? count_records($dl, "\n") : 0;
( run in 0.874 second using v1.01-cache-2.11-cpan-39bf76dae61 )