-
Notifications
You must be signed in to change notification settings - Fork 96
Open
Description
It would be nice to have coderef checks that work similar to hash/array/object. e.g:
use Test2::V0;
my $coderef = sub {
return 1, 1 if wantarray;
return 1;
};
is($coderef, code { call_list [1, 1]; call 1 }, 'coderef returns 1 in scalar context and 1, 1 in list context');Today, you have to do something like this:
use Test2::V0;
my $coderef = sub {
return 1, 1 if wantarray;
return 1;
};
is($coderef, meta {
prop reftype => 'CODE';
prop this => check_set(
validator(sub { my $ret = [$_->()]; ($ret->[0] == 1 and $ret->[1] == 1) ? 1 : 0 }),
validator(sub { $_->() == 1 ? 1 : 0 }),
);
}, 'coderef returns 1 in scalar context and 1, 1 in list context');If there's a simpler way to do this today, please let me know.
Metadata
Metadata
Assignees
Labels
No labels