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
|
#!/usr/local/bin/perl -w
use strict;
use Test::More qw(no_plan);
use Test::NoWarnings;
use lib qw( ../lib ./lib );
eval { chdir('t') };
use_ok('Nagios::Object');
package Nagios::Host;
sub foobar { shift->{foobar} || 'public' }
sub set_foobar {
my $self = shift;
if ( !exists( $self->{foobar} ) ) {
$self->{foobar} = 'public';
}
$self->_set( 'foobar', @_ );
}
package main;
can_ok( 'Nagios::Host', 'foobar' );
can_ok( 'Nagios::Host', 'set_foobar' );
my $host = Nagios::Host->new();
can_ok( $host, 'foobar' );
can_ok( $host, 'set_foobar' );
ok( $host->set_foobar("guessme"), "newly created set_foobar method works" );
is( $host->foobar, 'guessme', "use getter method to verify previous test" );
|