4 use Test::More tests => 18;
5 use Scalar::Util qw(weaken);
9 weaken(my $copy = $_[0]);
10 fail("variable is not a ref") unless ref $_[0];
12 ok(!defined($copy), $_[1]);
17 sub new { bless {}, shift }
20 { # basic behaviour - can we call without args?
24 my $code = $foo->$curry::curry(sub {
25 ok(shift->isa('Foo'), '$curry::curry object is correct class');
26 ok(!@_, '$curry::curry did not pick up any stray parameters');
29 fail('$curry::curry did not give us a coderef') unless ref($code) eq 'CODE';
31 ok($called, 'curried code was called');
35 ok($called, 'curried code executed successfully after original object goes out of scope');
38 { # parameter passthrough
42 my $code = $foo->$curry::curry(sub {
43 ok(shift->isa('Foo'), '$curry::curry object is correct class');
44 is_deeply(\@_, [qw(one two three)], 'curried code had the expected parameters');
47 fail('$curry::curry did not give us a coderef') unless ref($code) eq 'CODE';
48 $code->(qw(one two three));
49 ok($called, 'curried code was called');
52 $code->(qw(one two three));
53 ok($called, 'curried code again executed successfully after original object goes out of scope');
56 { # stashed parameters
60 my $code = $foo->$curry::curry(sub {
61 ok(shift->isa('Foo'), '$curry::curry object is correct class');
62 is_deeply(\@_, [qw(stashed parameters one two three)], 'curried code had the expected parameters');
64 }, qw(stashed parameters));
65 fail('$curry::curry did not give us a coderef') unless ref($code) eq 'CODE';
66 $code->(qw(one two three));
67 ok($called, 'curried code was called');
70 $code->(qw(one two three));
71 ok($called, 'curried code again executed successfully after original object goes out of scope');