Skip to content

Commit

Permalink
Added standard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nigel Horne committed Jun 12, 2020
1 parent f849f0b commit 0ddd2ab
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 5 deletions.
8 changes: 8 additions & 0 deletions MANIFEST
Expand Up @@ -6,8 +6,16 @@ MANIFEST This list of files
README.md
t/as_string.t
t/carp.t
t/coverage.t
t/distance.t
t/links.t
t/manifest.t
t/no404s.t
t/noopentickets.t
t/pod-cm.t
t/pod.t
t/port.t
t/spelling.t
t/unused.t
t/used.t
t/vars.t
10 changes: 5 additions & 5 deletions lib/Geo/Location/Point.pm
Expand Up @@ -174,16 +174,16 @@ sub as_string {
sub _sortoutcase {
my $self = shift;
my $field = lc(shift);
my $ret;
my $rc;

foreach (split(/ /, $field)) {
if($ret) {
$ret .= ' ';
if($rc) {
$rc .= ' ';
}
$ret .= ucfirst($_);
$rc .= ucfirst($_);
}

$ret;
return $rc;
}

=head2 attr
Expand Down
19 changes: 19 additions & 0 deletions t/coverage.t
@@ -0,0 +1,19 @@
use strict;
use warnings;
use Test::Most;

# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc tests => 1";
plan(skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage")
if $@;

# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;

# all_pod_coverage_ok();
pod_coverage_ok('Geo::Location::Point');
13 changes: 13 additions & 0 deletions t/manifest.t
@@ -0,0 +1,13 @@
#!perl -T

use strict;
use warnings;
use Test::Most;

unless ( $ENV{AUTHOR_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}

eval "use Test::CheckManifest 0.9";
plan skip_all => "Test::CheckManifest 0.9 required" if $@;
ok_manifest({ filter => [qr/.git/] });
13 changes: 13 additions & 0 deletions t/pod-cm.t
@@ -0,0 +1,13 @@
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::Most;

eval 'use Test::Pod::Spelling::CommonMistakes';
if($@) {
plan skip_all => 'Test::Pod::Spelling::CommonMistakes required for testing POD spelling';
} else {
all_pod_files_ok();
}
16 changes: 16 additions & 0 deletions t/pod.t
@@ -0,0 +1,16 @@
#!perl -T

use strict;
use warnings;
use Test::Most;

if(!$ENV{AUTHOR_TESTING}) {
plan(skip_all => 'Author tests not required for installation');
}

# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval("use Test::Pod $min_tp");
plan(skip_all => "Test::Pod $min_tp required for testing POD") if $@;

all_pod_files_ok();
11 changes: 11 additions & 0 deletions t/port.t
@@ -0,0 +1,11 @@
use Test::Most;

use warnings;
use strict;

eval 'use Test::Portability::Files';
plan skip_all => "Test::Portability::Files required for testing filenames portability" if $@;
# Turn off test_one_dot because even thoug use_file_find is off, T:P:F still
# tests files not distributed e.g. .travis.yml
options(use_file_find => 0, test_one_dot => 0);
run_tests();
19 changes: 19 additions & 0 deletions t/unused.t
@@ -0,0 +1,19 @@
#!perl -wT

use strict;
use warnings;
use Test::Most;

unless($ENV{AUTHOR_TESTING}) {
plan(skip_all => "Author tests not required for installation");
}

# eval 'use warnings::unused -global';
eval 'use warnings::unused';
if($@ || ($warnings::unused::VERSION < 0.04)) {
plan(skip_all => 'warnings::unused >= 0.04 needed for testing');
} else {
use_ok('Geo::Location::Point');
new_ok('Geo::Location::Point' => [ lat => 1, long => 2 ]);
plan tests => 2;
}
16 changes: 16 additions & 0 deletions t/used.t
@@ -0,0 +1,16 @@
#!perl -w

use strict;
use Test::Most;

unless($ENV{AUTHOR_TESTING}) {
plan(skip_all => "Author tests not required for installation");
}

eval 'use Test::Module::Used';
if($@) {
plan(skip_all => 'Test::Module::Used required for testing all modules needed');
} else {
my $used = Test::Module::Used->new(meta_file => 'MYMETA.yml');
$used->ok();
}
16 changes: 16 additions & 0 deletions t/vars.t
@@ -0,0 +1,16 @@
#!/usr/bin/env perl

use strict;
use warnings;

use Test::Most;

if(not $ENV{AUTHOR_TESTING}) {
plan(skip_all => 'Author tests not required for installation');
}

eval "use Test::Vars";

plan skip_all => "Test::Vars required for detecting unused variables" if $@;

all_vars_ok(ignore_vars => { '$self' => 0 });

0 comments on commit 0ddd2ab

Please sign in to comment.