<?xml version="1.0" encoding="windows-1252"?>
<node id="737829" title="Interesting testing idea ..." created="2009-01-21 09:20:09" updated="2009-01-21 09:20:09">
<type id="120">
perlmeditation</type>
<author id="85580">
dragonchild</author>
<data>
<field name="doctext">
The idea comes from [http://stuartsierra.com/2009/01/18/tests-are-code]. It's a neat idea, probably best suited for functional programming where one-liners are the norm and not the exception. BUT ... I think we could do it in Perl. Something like:
&lt;code&gt;
use Test::With;

sub foo : WithTests( 2 ) {
    my ($x, $y) = @_;
    return $x + y;
} with_test {
    cmp_ok( foo( 4, 3 ), '==', 7 );
    cmp_ok( foo( -6, 2 ), '==', -4 );
};
&lt;/code&gt;
I'm not even sure if that syntax will work, but it looks appealing. :-)
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-85580"&gt;
&lt;hr&gt;
My criteria for good software:
&lt;ol&gt;
&lt;li&gt;Does it work?
&lt;li&gt;Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
&lt;/ol&gt;
&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
