1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
use strict;
use warnings;
## skip Test::Tabs
use Test::More;
use Test::Requires '5.008001';
use Test::Fatal;
use FindBin qw($Bin);
use lib "$Bin/lib";
use MyTest::TestClass::Scalar;
my $CLASS = q[MyTest::TestClass::Scalar];
## make_getter
can_ok( $CLASS, 'my_make_getter' );
subtest 'Testing my_make_getter' => sub {
my $e = exception {
my $object = $CLASS->new( attr => 10 );
my $getter = $object->my_make_getter;
$object->_set_attr( 11 );
is( $getter->(), 11, q{$getter->() is 11} );
};
is( $e, undef, 'no exception thrown running make_getter example' );
};
## make_setter
can_ok( $CLASS, 'my_make_setter' );
subtest 'Testing my_make_setter' => sub {
my $e = exception {
my $object = $CLASS->new( attr => 10 );
my $setter = $object->my_make_setter;
$setter->( 11 );
is( $object->attr, 11, q{$object->attr is 11} );
};
is( $e, undef, 'no exception thrown running make_setter example' );
};
## scalar_reference
can_ok( $CLASS, 'my_scalar_reference' );
subtest 'Testing my_scalar_reference' => sub {
my $e = exception {
my $object = $CLASS->new( attr => 10 );
my $ref = $object->my_scalar_reference;
$$ref++;
is( $object->attr, 11, q{$object->attr is 11} );
};
is( $e, undef, 'no exception thrown running scalar_reference example' );
};
done_testing;
|