my
$CLASS
=
q[MyTest::TestClass::Code]
;
can_ok(
$CLASS
,
'my_execute'
);
subtest
'Testing my_execute'
=>
sub
{
my
$e
= exception {
my
$coderef
=
sub
{
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
$object
->my_execute( 1, 2, 3 );
};
is(
$e
,
undef
,
'no exception thrown running execute example'
);
};
can_ok(
$CLASS
,
'my_execute_list'
);
subtest
'Testing my_execute_list'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_list( 1, 2, 3 );
is_deeply(
$result
, [
'code'
],
q{$result deep match}
);
ok(
$context
,
q{$context is true}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_list example'
);
};
can_ok(
$CLASS
,
'my_execute_method'
);
subtest
'Testing my_execute_method'
=>
sub
{
my
$e
= exception {
my
$coderef
=
sub
{
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
$object
->my_execute_method( 1, 2, 3 );
};
is(
$e
,
undef
,
'no exception thrown running execute_method example'
);
};
can_ok(
$CLASS
,
'my_execute_method_list'
);
subtest
'Testing my_execute_method_list'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_method_list( 1, 2, 3 );
is_deeply(
$result
, [
'code'
],
q{$result deep match}
);
ok(
$context
,
q{$context is true}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_method_list example'
);
};
can_ok(
$CLASS
,
'my_execute_method_scalar'
);
subtest
'Testing my_execute_method_scalar'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_method_scalar( 1, 2, 3 );
is(
$result
,
'code'
,
q{$result is 'code'}
);
ok( !(
$context
),
q{$context is false}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_method_scalar example'
);
};
can_ok(
$CLASS
,
'my_execute_method_void'
);
subtest
'Testing my_execute_method_void'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_method_void( 1, 2, 3 );
is(
$result
,
undef
,
q{$result is undef}
);
is(
$context
,
undef
,
q{$context is undef}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_method_void example'
);
};
can_ok(
$CLASS
,
'my_execute_scalar'
);
subtest
'Testing my_execute_scalar'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_scalar( 1, 2, 3 );
is(
$result
,
'code'
,
q{$result is 'code'}
);
ok( !(
$context
),
q{$context is false}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_scalar example'
);
};
can_ok(
$CLASS
,
'my_execute_void'
);
subtest
'Testing my_execute_void'
=>
sub
{
my
$e
= exception {
my
$context
;
my
$coderef
=
sub
{
$context
=
wantarray
();
'code'
};
my
$object
=
$CLASS
->new(
attr
=>
$coderef
);
my
$result
=
$object
->my_execute_void( 1, 2, 3 );
is(
$result
,
undef
,
q{$result is undef}
);
is(
$context
,
undef
,
q{$context is undef}
);
};
is(
$e
,
undef
,
'no exception thrown running execute_void example'
);
};
done_testing;