Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Last active November 21, 2018 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j1n3l0/921a07a004c034cb7b7266003abcff9d to your computer and use it in GitHub Desktop.
Save j1n3l0/921a07a004c034cb7b7266003abcff9d to your computer and use it in GitHub Desktop.
use Test2::V0;
use PerlX::Maybe qw< :all >;
subtest 'provided_deref' => sub {
my $object = mock {} => (
add => [
count => sub { 1 },
interval => sub { 1 },
update => sub {
+{
provided_deref $_[0]->count, {
count => $_[0]->count,
interval => $_[0]->interval,
},
};
},
],
);
like(
$object->update,
{
count => qr/^[0-9]+$/,
interval => qr/^[0-9]+$/,
},
'should dereference based on a condition',
);
};
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment