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

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


#!/usr/bin/perl

use lib '..';
use Memoize 'memoize', 'unmemoize';

sub reff {
  return [1,2,3];

}

sub listf {
  return (1,2,3);
}

print "1..6\n";

memoize 'reff', LIST_CACHE => 'MERGE';
print "ok 1\n";
memoize 'listf';
print "ok 2\n";

$s = reff();
@a = reff();
print @a == 1 ? "ok 3\n" : "not ok 3\n";

$s = listf();
@a = listf();
print @a == 3 ? "ok 4\n" : "not ok 4\n";

unmemoize 'reff';
memoize 'reff', LIST_CACHE => 'MERGE';
unmemoize 'listf';
memoize 'listf';

@a = reff();
$s = reff();
print @a == 1 ? "ok 5\n" : "not ok 5\n";

@a = listf();
$s = listf();
print @a == 3 ? "ok 6\n" : "not ok 6\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 [email protected].