News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Perl Programming Styles

Started by thiruvasagamani, Nov 13, 2008, 09:39 PM

Previous topic - Next topic

thiruvasagamani

Perl Programming

Perl Programming Styles

    * Here's some of the many ways people write their tests:

          o t/op/sysio.t
            print 'not ' unless (syswrite(O, $a, 2) == 2);
            print "ok 20\n";

          o ext/Cwd/t/cwd.t
            print +($getcwd eq $start ? "" : "not "), "ok 4\n";

          o t/pod/plainer.t
            unless( $returned eq $expected ) {
            print map { s/^/\#/mg; $_; }
            map {+$_} # to avoid readonly values
            "EXPECTED:\n", $expected, "GOT:\n", $returned;
            print "not ";
            }
            printf "ok %d\n", ++$test;

    * Maintenance nightmare.

I'm ok, you're ok

#!/usr/bin/perl -w
use Test::Simple tests => 1;
ok( 1 + 1 == 2 );

    * "ok" is the backbone of Perl testing.

          o If the expression is true, the test pass.

          o False, it fails.

    * Every conceivable test can be performed just using ok()
Thiruvasakamani Karnan