File: 99config-extend.t

package info (click to toggle)
libnagios-object-perl 0.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 512 kB
  • ctags: 112
  • sloc: perl: 1,804; makefile: 53
file content (40 lines) | stat: -rw-r--r-- 889 bytes parent folder | download | duplicates (2)
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
#!/usr/local/bin/perl -w
use strict;
use Test::More qw(no_plan);
use lib qw( ../lib ./lib );
eval { chdir('t') };

use_ok( 'Nagios::Object' );


package Nagios::Host;
{
    no warnings; # so use of valid_fields doesn't bug us
    $Nagios::Host::valid_fields->{foobar} = [ 'STRING', 0, 0, 0 ];
}
sub foobar { shift->{foobar}->() || 'public' }
sub set_foobar {
    my $self = shift;
    if ( !exists($self->{foobar}) ) {
        $self->{foobar} = 'public';
    }
    $self->_set('foobar', @_);
}

#sub set_foobar { $_[0]->{foobar} = $_[1] }

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" );