Memoize-Lift
view release on metacpan or search on metacpan
our($b, @b);
is $b, 1;
for(my $i = 0; $i != 0; $i++) {
push @b, [ $i, lift(10 + ++$b) ];
}
is $b, 1;
is_deeply \@b, [];
our $c;
BEGIN { $c = 1; }
sub cc() { lift($c) }
$c = 2;
is cc(), 1;
$c = 3;
is cc(), 1;
1;
t/hint_in.t view on Meta::CPAN
use warnings;
use strict;
package Foo;
use Test::More tests => 3;
BEGIN { use_ok "Memoize::Lift", qw(lift); }
sub cc() { lift(__PACKAGE__) }
is cc(), "Foo";
is cc(), "Foo";
1;
use warnings;
use strict;
use Test::More tests => 10;
BEGIN { use_ok "Memoize::Lift", qw(lift); }
our($a, $i);
BEGIN { $a = 2; }
sub aa() { [ "x", lift(($i++, $a)), "y" ] }
is $i, 1;
$a = 3;
is_deeply aa(), [ "x", 2, "y" ];
is $i, 1;
$a = 4;
is_deeply aa(), [ "x", 2, "y" ];
is $i, 1;
sub bb() { no warnings "void"; [ "x", lift((11, 12)), "y" ] }
is_deeply bb(), [ "x", 12, "y" ];
is_deeply bb(), [ "x", 12, "y" ];
sub cc() { [ "x", lift(()), "y" ] }
is_deeply cc(), [ "x", undef, "y" ];
is_deeply cc(), [ "x", undef, "y" ];
1;
t/precedence.t view on Meta::CPAN
use warnings;
use strict;
use Test::More tests => 9;
BEGIN { use_ok "Memoize::Lift", qw(lift); }
our($a, $b);
BEGIN { $a = 20; $b = 1; }
sub aa() { lift($a) + $b }
sub bb() { lift $a + $b }
sub cc() { lift($a) | $b }
sub dd() { lift $a | $b }
is aa(), 21;
is bb(), 21;
is cc(), 21;
is dd(), 21;
$a = 40; $b = 2;
is aa(), 22;
is bb(), 21;
is cc(), 22;
is dd(), 22;
use warnings;
use strict;
use Test::More tests => 6;
BEGIN { use_ok "Memoize::Lift", qw(lift); }
our($a, $i);
BEGIN { $a = undef; }
sub aa() { lift(do { $i++; $a }) }
is $i, 1;
$a = 2;
is aa(), undef;
is $i, 1;
$a = 3;
is aa(), undef;
is $i, 1;
1;
( run in 1.152 second using v1.01-cache-2.11-cpan-524268b4103 )