Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.2 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Test::Assertions 1.054

    Download button

    No screenshots available
    Downloads: 471  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    John Alden | More programs
    Perl Artistic License / FREE
    August 23rd, 2007, 12:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Test::Assertions description

    A module is a simple set of building blocks for both unit and runtime testing.

    Test::Assertions module is a simple set of building blocks for both unit and runtime testing.

    SYNOPSIS

    #ASSERT does nothing
    use Test::Assertions;

    #ASSERT warns "Assertion failure"...
    use Test::Assertions qw(warn);

    #ASSERT dies with "Assertion failure"...
    use Test::Assertions qw(die);

    #ASSERT warns "Assertion failure"... with stack trace
    use Test::Assertions qw(cluck);

    #ASSERT dies with "Assertion failure"... with stack trace
    use Test::Assertions qw(confess);

    #ASSERT prints ok/not ok
    use Test::Assertions qw(test);

    #Will cause an assertion failure
    ASSERT(1 == 0);

    #Optional message
    ASSERT(0 == 1, "daft");

    #Checks if coderef dies
    ASSERT(
    DIED( sub {die()} )
    );

    #Check if perl compiles OK
    ASSERT(
    COMPILES('program.pl')
    );

    #Deep comparisons
    ASSERT(
    EQUAL(@a, @b),
    "lists of widgets match" # an optional message
    );
    ASSERT(
    EQUAL(%a, %b)
    );

    #Compare to a canned value
    ASSERT(
    EQUALS_FILE($foo, 'bar.dat'),
    "value matched stored value"
    );

    #Compare to a canned value (regex match using file contents as regex)
    ASSERT(
    MATCHES_FILE($foo, 'bar.regex')
    );

    #Compare file contents
    ASSERT(
    FILES_EQUAL('foo.dat', 'bar.dat')
    );

    #returns 'not ok for Foo::Bar Tests (1 errors in 3 tests)'
    ASSESS(
    ['ok 1', 'not ok 2', 'A comment', 'ok 3'], 'Foo::Bar Tests', 0
    );

    #Collate results from another test script
    ASSESS_FILE("test.pl");

    #File routines
    $success = WRITE_FILE('bar.dat', 'hello world');
    ASSERT( WRITE_FILE('bar.dat', 'hello world'), 'file was written');
    $string = READ_FILE('example.out');
    ASSERT( READ_FILE('example.out'), 'file has content' );
    The helper routines don't need to be used inside ASSERT():
    if ( EQUALS_FILE($string, $filename) ) {
    print "File hasn't changed - skippingn";
    } else {
    my $rc = run_complex_process($string);
    print "File changed - string was reprocessed with result '$rc'n";
    }

    ($boolean, $output) = COMPILES('file.pl');
    # or...
    my $string;
    ($boolean, $standard_output) = COMPILES('file.pl', 1, $string);
    # $string now contains standard error, separate from $standard_output
    In test mode:
    use Test::Assertions qw(test);
    plan tests => 4;
    plan tests; #will attempt to deduce the number
    only (1,2); #Only report ok/not ok for these tests
    ignore 2; #Skip this test

    #In test/ok mode...
    use Test::Assertions qw(test/ok);
    ok(1); #synonym for ASSERT


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    build blocks | runtime testing | unit testing | blocks | builder | unit

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM