Skip to content

Commit

Permalink
Add some (very basic) tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Aug 11, 2017
1 parent 7f84e7f commit 212a394
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Makefile.PL
@@ -0,0 +1,30 @@
use ExtUtils::MakeMaker;

WriteMakefile(
NAME => 'Genealogy::Chart::SVG',
VERSION_FROM => 'lib/Genealogy/Chart/SVG.pm',
LICENSE => 'perl_5',
MIN_PERL_VERSION => '5.10.0',

BUILD_REQUIRES => {
'Test::More' => 0,
'ExtUtils::MakeMaker' => 0,
SVG => 0,
Moose => 0,
},
PREREQ_PM => {
SVG => 0,
Moose => 0,
},
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'git://github.com/davorg/genealogy-chart-svg.git',
web => 'https://github.com/davorg/genealgoy-chart-svge',
},
},
},
EXE_FILES => [ 'bin/chart' ],
);
32 changes: 32 additions & 0 deletions lib/Genealogy/Chart/SVG.pm
@@ -1,3 +1,13 @@
=head1 NAME
Genealogy::Chart::SVG
=head1 DESCRIPTION
Perl extension for drawing Genealogical charts using SVG.
=cut

package Genealogy::Chart::SVG;

use strict;
Expand Down Expand Up @@ -115,6 +125,12 @@ has bar_outline_colour => (
default => 'rgb(0,0,0)',
);

=head1 METHODS
=head2 BUILD
=cut

sub BUILD {
my $self = shift;

Expand Down Expand Up @@ -145,6 +161,10 @@ sub BUILD {
return $self;
}

=head2 person
=cut

# Produce a bar containing the details of one person.
sub person {
my $self = shift;
Expand Down Expand Up @@ -188,13 +208,21 @@ sub person {
# The 3rd generation appears 1/8, 3/8, 5/8 and 7/8 down the page.
# etc ...

=head2 y_pos
=cut

sub y_pos {
croak 'No generation passed to y_pos()' unless @_;

# TODO: int?
return num( $_[0] ) / den( $_[0] );
}

=head2 num
=cut

# No idea how this works. But it does.
sub num {
my $num = shift;
Expand All @@ -212,6 +240,10 @@ sub num {
# So convert the persons number to a generation number, and calculate
# 2 ** the generation number.

=head2 den
=cut

sub den {
my $num = shift;

Expand Down
17 changes: 17 additions & 0 deletions t/01-basic.t
@@ -0,0 +1,17 @@

use Test::More;

use Genealogy::Chart::SVG;

my $gcs = Genealogy::Chart::SVG->new;

$gcs->person({
id => 1,
name => 'Mr Example',
birth => 1900,
death => 2000,
});

ok(my $chart = $gcs->xmlify);

done_testing();
10 changes: 10 additions & 0 deletions t/load.t
@@ -0,0 +1,10 @@
use Test::More;

BEGIN {
use_ok 'Genealogy::Chart::SVG';
}

ok(my $tl = Genealogy::Chart::SVG->new);
isa_ok($tl, 'Genealogy::Chart::SVG');

done_testing;
5 changes: 5 additions & 0 deletions t/pod-coverage.t
@@ -0,0 +1,5 @@
use Test::More;
eval "use Test::Pod::Coverage 1.00";
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
all_pod_coverage_ok();

7 changes: 7 additions & 0 deletions t/pod.t
@@ -0,0 +1,7 @@
use Test::More;

eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();

done_testing;

0 comments on commit 212a394

Please sign in to comment.