diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-16 21:47:00 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-16 21:47:00 +0000 |
commit | a0cb39004565ec2396fbdb3f1949b8f13304208e (patch) | |
tree | 67b23b5671a1bf84313263478ddd1c4894a7b7ad /lib/Memoize/t/expire_module_n.t | |
parent | 58a21a9b07f5f6666d09bb8c0b9bf9150baca513 (diff) | |
download | perl-a0cb39004565ec2396fbdb3f1949b8f13304208e.tar.gz |
Integrate Memoize 0.64. Few tweaks were required in
the test scripts. Note that the speed and expire*
tests take several dozen seconds to run.
p4raw-id: //depot/perl@10645
Diffstat (limited to 'lib/Memoize/t/expire_module_n.t')
-rw-r--r-- | lib/Memoize/t/expire_module_n.t | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/Memoize/t/expire_module_n.t b/lib/Memoize/t/expire_module_n.t new file mode 100644 index 0000000000..b6b4521f7b --- /dev/null +++ b/lib/Memoize/t/expire_module_n.t @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use lib '..'; +use Memoize; + +my $n = 0; + + +print "1..21\n"; + +++$n; print "ok $n\n"; + +$RETURN = 1; + +%CALLS = (); +sub call { +# print "CALL $_[0] => $RETURN\n"; + ++$CALLS{$_[0]}; + $RETURN; +} + +memoize 'call', + SCALAR_CACHE => ['TIE', 'Memoize::Expire', NUM_USES => 2], + LIST_CACHE => 'FAULT'; + +# $Memoize::Expire::DEBUG = 1; +++$n; print "ok $n\n"; + +# 3--6 +for (0,1,2,3) { + print "not " unless call($_) == 1; + ++$n; print "ok $n\n"; +} + +# 7--10 +for (keys %CALLS) { + print "not " unless $CALLS{$_} == (1,1,1,1)[$_]; + ++$n; print "ok $n\n"; +} + +# 11--13 +$RETURN = 2; +++$n; print ((call(1) == 1 ? '' : 'not '), "ok $n\n"); # 1 expires +++$n; print ((call(1) == 2 ? '' : 'not '), "ok $n\n"); # 1 gets new val +++$n; print ((call(2) == 1 ? '' : 'not '), "ok $n\n"); # 2 expires + +# 14--17 +$RETURN = 3; +for (0,1,2,3) { + # 0 expires, 1 expires, 2 gets new val, 3 expires + print "not " unless call($_) == (1,2,3,1)[$_]; + ++$n; print "ok $n\n"; +} + +for (0,1,2,3) { + print "not " unless $CALLS{$_} == (1,2,2,1)[$_]; + ++$n; print "ok $n\n"; +} + + |