Skip to content

Commit

Permalink
2 syntax pod corrections + 2 new test files that increase to coverage of
Browse files Browse the repository at this point in the history
sub's tested with mostly empty data.
  • Loading branch information
Steve Thorn committed Feb 22, 2018
1 parent b41aa51 commit 484e3be
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/GraphViz2.pm
Expand Up @@ -72,9 +72,9 @@ has global =>

has graph =>
(
default => sub{return ''},
default => sub{return {} },

This comment has been minimized.

Copy link
@ThornyS

ThornyS Feb 22, 2018

Owner

initialisation in the BEGIN sub attempts to use 'default' as 'HashRef' which errors when it sees empty string.
Changed as part of expanding test coverage for subs

is => 'rw',
#isa => HashRef,
isa => HashRef,
required => 0,
);

Expand Down Expand Up @@ -1742,7 +1742,7 @@ $level defaults to 'debug', and $message defaults to ''.
If called with $level eq 'error', it dies with $message.
=head2 logger($logger_object])
=head2 logger($logger_object)

This comment has been minimized.

Copy link
@ThornyS

ThornyS Feb 22, 2018

Owner

podchecker spotted a failed link as a result of what looks like a typo L</logger($logger_object)> , so removed trailing ']'

Gets or sets the log object.
Expand Down
2 changes: 1 addition & 1 deletion lib/GraphViz2/Filer.pm
Expand Up @@ -159,7 +159,7 @@ It returns a new object of type C<GraphViz2::Filer>.
=head1 Methods
=head1 get_annotations()
=head2 get_annotations()

This comment has been minimized.

Copy link
@ThornyS

ThornyS Feb 22, 2018

Owner

Set the head(n) hierarchy order spotted by podchecker.

Returns a hash (sic) keyed by *.pl name, with the values being the text off line 3 of each script.
Expand Down
53 changes: 53 additions & 0 deletions t/test_more_methods.t
@@ -0,0 +1,53 @@
use strict;
use utf8;
use warnings;
use warnings qw(FATAL utf8); # Fatalize encoding glitches.
use open qw(:std :utf8); # Undeclared streams in UTF-8.
use charnames qw(:full :short); # Unneeded in v5.16.

use Data::Dumper;
use Test::More;
use GraphViz2;

# ------------------------------------------------

my $GraphViz2 = GraphViz2->new();
my $count = 0;

my %methods = (
add_node => { id => 1, args => { name => 'TestNode1', label => 'n1' } },
add_edge => { id => 2, args => { from => 'TestNode1', to => '' } },
default_subgraph => { id => 3, args => {} },
escape_some_chars => { id => 4, args => { $GraphViz2, "abc123[]()" } },
push_subgraph => {
id => 5,
args => {
name => 'subgraph_test',
edge => {},
graph => { bgcolor => 'grey', label => 'subgraph_test' }
}
},
pop_subgraph => { id => 6, args => {} },
report_valid_attributes => { id => 7, args => {} },
run => { id => 8, args => {} },
run_map => { id => 9, args => {} },
run_mapless => { id => 10, args => {} },
);
foreach my $sub ( sort { $methods{$a}{id} <=> $methods{$b}{id} } keys %methods )
{

# Check we can call this function/method/sub
$count++;
can_ok( $GraphViz2, $sub );

$count++;
ok(
$GraphViz2->$sub( %{ $methods{$sub}{'args'} } ),
"Run $sub with -> "
. join(
", ", map { "$_:$methods{$sub}{'args'}{$_}" } keys %{ $methods{$sub}{'args'} }
)
);
}
done_testing($count);

18 changes: 18 additions & 0 deletions t/test_new.t
@@ -0,0 +1,18 @@
use strict;
use utf8;
use warnings;
use warnings qw(FATAL utf8); # Fatalize encoding glitches.
use open qw(:std :utf8); # Undeclared streams in UTF-8.
use charnames qw(:full :short); # Unneeded in v5.16.

use Test::More;

# ------------------------------------------------

BEGIN{ use_ok('GraphViz2'); }

my($count) = 1; # Counting the use_ok above.
$count++;
my $GraphViz2 = new_ok('GraphViz2');
done_testing($count);

0 comments on commit 484e3be

Please sign in to comment.