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::weak(sub {
25 ok(shift->isa('Foo'), '$curry::weak object is correct class');
26 ok(!@_, '$curry::weak did not pick up any stray parameters on the way in');
29 fail('$curry::weak::curry did not give us a coderef') unless ref($code) eq 'CODE';
31 ok($called, 'curried code was called');
32 dispose_ok($foo, '$foo departs without a fight');
35 ok(!$called, '... and we can still use the coderef as a no-op');
38 { # parameter passthrough
42 my $code = $foo->$curry::weak(sub {
43 ok(shift->isa('Foo'), '$curry::weak object is correct class');
44 is_deeply(\@_, [qw(stashed parameters one two three)], 'args passed as expected');
46 }, qw(stashed parameters));
47 fail('$curry::weak::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');
50 dispose_ok($foo, '$foo departs without a fight');
53 ok(!$called, '... and we can still use the coderef as a no-op');