expmod_t.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
use lib '..';
use Memoize;
BEGIN {
# $SLOW_TESTS = 1;
} else {
}
}
my $DEBUG = 0;
my $n = 0;
$| = 1;
if (-e '.fast') {
print "1..0\n";
exit 0;
}
# Perhaps nobody will notice if we don't say anything
# print "# Warning: I'm testing the timed expiration policy.\n# This will take about thirty seconds.\n";
print "1..15\n";
$| = 1;
# (1)
++$n; print "ok $n\n";
# (2)
++$n; print "ok $n\n";
sub close_enough {
# print "Close enough? @_[0,1]\n";
}
sub very_close {
# print "Close enough? @_[0,1]\n";
}
my $t0;
sub start_timer {
$t0 = time;
}
sub wait_until {
return if $diff <= 0;
}
sub now {
# print "NOW: @_ ", time(), "\n";
time;
}
memoize 'now',
LIST_CACHE => 'FAULT'
;
# (3)
++$n; print "ok $n\n";
# (4-6)
# T
start_timer();
for (1,2,3) {
++$n;
print "ok $n\n";
sleep 6 if $_ < 3;
}
# values will now expire at T=15, 21, 27
# it is now T=12
# T+12
for (1,2,3) {
}
# (7-9)
# T+12
foreach (1,2,3) {
++$n;
print "ok $n\n";
} else {
}
}
# (10)
++$n; print "ok $n\n";
# (11-12)
# T+18
foreach (2,3) { # Should not have expired yet.
++$n;
print "ok $n\n";
}
# (13)
# T+24
++$n; print "ok $n\n";
# (14-15)
# T+24
foreach (1,3) { # 1 is good again because it was recomputed after it expired
++$n;
print "ok $n\n";
} else {
}
}