Plan 9 from Bell Labs’s /usr/web/sources/contrib/gabidiaz/root/sys/src/cmd/perl/lib/Memoize/t/unmemoize.t

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/usr/bin/perl

use lib '..';
use Memoize qw(memoize unmemoize);

print "1..5\n";

eval { unmemoize('f') };	# Should fail
print (($@ ? '' : 'not '), "ok 1\n");

{ my $I = 0;
  sub u { $I++ }
}
memoize('u');
my @ur = (&u, &u, &u);
print (("@ur" eq "0 0 0") ? "ok 2\n" : "not ok 2\n");

eval { unmemoize('u') };	# Should succeed
print ($@ ? "not ok 3\n" : "ok 3\n");

@ur = (&u, &u, &u);
print (("@ur" eq "1 2 3") ? "ok 4\n" : "not ok 4\n");

eval { unmemoize('u') };	# Should fail
print ($@ ? "ok 5\n" : "not ok 5\n");


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.