Acme-CreatingCPANModules

 view release on metacpan or  search on metacpan

slides/slide15.html  view on Meta::CPAN

<div id="content">
<div class="top_spacer"></div>

<h1>t/boilerplate.t</h1>
<pre class="formatter_pre">#!perl -T

use strict;
use warnings;
use Test::More tests =&gt; 3;

sub not_in_file_ok {
    my &#40;$filename, %regex&#41; = @_;
    open my $fh, &#34;&lt;&#34;, $filename
        or die &#34;couldn&#39;t open $filename for reading: $!&#34;;

    my %violated;

    while &#40;my $line = &lt;$fh&gt;&#41; {
        while &#40;my &#40;$desc, $regex&#41; = each %regex&#41; {
            if &#40;$line =~ $regex&#41; {
                push @{$violated{$desc}||=[]}, $.;

slides/slide15.html  view on Meta::CPAN

    }

    if &#40;%violated&#41; {
        fail&#40;&#34;$filename contains boilerplate text&#34;&#41;;
        diag &#34;$_ appears on lines @{$violated{$_}}&#34; for keys %violated;
    } else {
        pass&#40;&#34;$filename contains no boilerplate text&#34;&#41;;
    }
}

not_in_file_ok&#40;README =&gt;
    &#34;The README is used...&#34;       =&gt; qr/The README is used/,
    &#34;&#39;version information here&#39;&#34;  =&gt; qr/to provide version information/,
&#41;;

not_in_file_ok&#40;Changes =&gt;
    &#34;placeholder date/time&#34;       =&gt; qr&#40;Date/time&#41;
&#41;;

sub module_boilerplate_ok {
    my &#40;$module&#41; = @_;
    not_in_file_ok&#40;$module =&gt;
        &#39;the great new $MODULENAME&#39;   =&gt; qr/ - The great new /,
        &#39;boilerplate description&#39;     =&gt; qr/Quick summary of what the module/,
        &#39;stub function definition&#39;    =&gt; qr/function[12]/,
    &#41;;
}

module_boilerplate_ok&#40;&#39;lib/Acme/CreatingCPANModules.pm&#39;&#41;;
</pre>

</div>



( run in 0.739 second using v1.01-cache-2.11-cpan-cc502c75498 )