File: 01_OO.t

package info (click to toggle)
libconfig-auto-perl 0.44-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 164 kB
  • sloc: perl: 397; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,399 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;

use Test::More 'no_plan';


my $Class   = 'Config::Auto';
use_ok( $Class );

my @Formats = $Class->formats;
ok( scalar(@Formats),           "Retrieved available formats" );


### try to create some objects using all formats
{   ok( 1,                      "Building object for every format" );
    for my $format (@Formats) {
        my $obj = $Class->new( source => $0, format => $format );

        ok( $obj,               "   Built object from '$format'" );
        isa_ok( $obj, $Class,   "       Object" );
        is( $obj->format, $format,
                                "       Format as expected" );
    }
}

### grab one format, do all the accessor and sanity checks on it
{   ok( 1,                      "Testing data retrieval methods" );
    my $obj = $Class->new( source => $0 );

    ok( $obj,                   "   Object created" );
    isa_ok( $obj, $Class,       "       Object" );
    isa_ok( $obj->data, 'ARRAY',"           Data retrieved" );
    ok( -e $obj->file,          "           Filename found" );
    ok( ref( $obj->fh ),        "           Filehandle found" );
    ok( $obj->as_string,        "           Contents retrieved" );

    my $href = $obj->score;
    ok( $href,                  "       Score computed" );
    isa_ok( $href, 'HASH',      "           Return value" );
    ok( scalar(keys(%$href)),   "           Scores found" );
}