Acme-CreatingCPANModules

 view release on metacpan or  search on metacpan

slides/slide15.html  view on Meta::CPAN

    window.close();
}

function handleKey(e) {
    var key;
    if (e == null) {
        // IE
        key = event.keyCode
    } 
    else {
        // Mozilla
        if (e.altKey || e.ctrlKey) {
            return true
        }
        key = e.which
    }
    switch(key) {
        case 8: prevSlide(); break
        case 13: nextSlide(); break
        case 32: nextSlide(); break
        case 81: closeSlide(); break
        case 105: indexSlide(); break
        case 110: nextSlide(); break
        case 112: prevSlide(); break
        case 115: startSlide(); break
        default: //xxx(e.which)
    }
}

document.onkeypress = handleKey
// END controls.js

</script>
</head>
<body>
<div id="topbar">
<table width='100%'>
<tr>
<td width="13%">CPAN</td>
<td align="center" width="73%">
    <a accesskey="s" href="start.html">Creating CPAN modules</a>
</td>
<td align="right" width="13%">
    #15
</td>
</tr>
</table>
</div>
<!-- END top -->

<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}||=[]}, $.;
            }
        }
    }

    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>
<!-- BEGIN bottom -->
<div id="bottombar">
<table width="100%">
<tr>
<td align="left" valign="middle">
    <div style="display:none">
    <a accesskey='p' href="slide14.html">&lt; &lt; Previous</a> |
    <a accesskey='i' href="index.html">Index</a> |
    <a accesskey='n' href="slide16.html">Next &gt;&gt;</a>
    </div>
</td>
<td align="right" valign="middle">
    Copyright &copy; 2005 Jos&eacute; Castro
</td>
</tr>
</table>
</div> 
<div id="logo"></div>
<div class="spacer">
<a name="end"></a>
</div>
</body>
</html>


<!-- END slide -->



( run in 1.857 second using v1.01-cache-2.11-cpan-9581c071862 )