source: subversion/applications/lib/Geo-OSM-MapFeatures/t/boilerplate.t @ 11736

Revision 11736, 2.0 KB checked in by bobkare, 5 years ago (diff)

Initial release of Geo::OSM::MapFeatures?, which parses and represents map features as a perl object

Line 
1#!perl -T
2
3use strict;
4use warnings;
5use Test::More tests => 14;
6
7sub not_in_file_ok {
8    my ($filename, %regex) = @_;
9    open( my $fh, '<', $filename )
10        or die "couldn't open $filename for reading: $!";
11
12    my %violated;
13
14    while (my $line = <$fh>) {
15        while (my ($desc, $regex) = each %regex) {
16            if ($line =~ $regex) {
17                push @{$violated{$desc}||=[]}, $.;
18            }
19        }
20    }
21
22    if (%violated) {
23        fail("$filename contains boilerplate text");
24        diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
25    } else {
26        pass("$filename contains no boilerplate text");
27    }
28}
29
30sub module_boilerplate_ok {
31    my ($module) = @_;
32    not_in_file_ok($module =>
33        'the great new $MODULENAME'   => qr/ - The great new /,
34        'boilerplate description'     => qr/Quick summary of what the module/,
35        'stub function definition'    => qr/function[12]/,
36    );
37}
38
39not_in_file_ok(README =>
40  "The README is used..."       => qr/The README is used/,
41  "'version information here'"  => qr/to provide version information/,
42);
43
44not_in_file_ok(Changes =>
45  "placeholder date/time"       => qr(Date/time)
46);
47
48module_boilerplate_ok('lib/Geo/OSM/MapFeatures.pm');
49module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature.pm');
50module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Key.pm');
51module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Type.pm');
52module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value.pm');
53module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/Date.pm');
54module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/NumWithUnit.pm');
55module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/Range.pm');
56module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/Num.pm');
57module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/Time.pm');
58module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/Userdef.pm');
59module_boilerplate_ok('lib/Geo/OSM/MapFeatures/Feature/Value/List.pm');
Note: See TracBrowser for help on using the repository browser.