Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod corrections + 2 more test files for more explicit direct sub tests #4

Merged
merged 2 commits into from Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {} },
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)

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()

Returns a hash (sic) keyed by *.pl name, with the values being the text off line 3 of each script.

Expand Down
72 changes: 72 additions & 0 deletions t/test_more_methods.t
@@ -0,0 +1,72 @@
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(
im_meta => { URL => "http://savage.net.au/maps/demo.4.html" }
);
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_map => {
id => 8,
subname => 'run',
args => {
format => 'png',
output_file => 't/test_more_run_map.png',
im_output_file => 't/test_more_run_map.map',
im_format => 'cmapx',
},
},
run_mapless => {
id => 9,
subname => 'run',
args => {
format => 'png',
output_file => 't/test_more_run_mapless.png',
},
},
);
foreach my $sub ( sort { $methods{$a}{id} <=> $methods{$b}{id} } keys %methods )
{

my $subname = defined $methods{$sub}{'subname'} ? $methods{$sub}{'subname'} : $sub;

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

$count++;
ok(
$GraphViz2->$subname( %{ $methods{$sub}{'args'} } ),
"Run $subname 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);