NAME ^

Test::Builder::Tester - Parrot extension for testing test modules

SYNOPSIS ^

        # load this library
        load_bytecode 'library/Test/Builder/Tester.pir'

        # grab the subroutines you want to use
        .local pmc plan
        .local pmc test_out
        .local pmc test_diag
        .local pmc test_test

        plan      = find_global 'Test::Builder::Tester', 'plan'
        test_out  = find_global 'Test::Builder::Tester', 'test_out'
        test_diag = find_global 'Test::Builder::Tester', 'test_diag'
        test_test = find_global 'Test::Builder::Tester', 'test_test'

        # create a new Test::Builder object
        .local int tb_type
        .local pmc tb_args
        .local pmc test

        find_type tb_type, 'Test::Builder'
        tb_args = new .Hash
        test    = new tb_type, tb_args

        # set your test plan
        plan( 4 )

        # test a passing test
        test_out( 'ok 1 - hi' )
        test.'ok'( 1, 'hi' )
        test_test( 'passing test')

        # test a test with some diagnostics
        test_out( 'ok 3 - A message' )
        test_diag( "some\nlines" )
        test.ok( 1, 'A message' )
        test.diag( 'some' )
        test.diag( 'lines' )
        test_test( 'passing test with diagnostics' )

        # clean up
        test.'finish'()

DESCRIPTION ^

Test::Builder::Tester is a pure-Parrot library for testing testing modules built on Test::Builder. It allows you to describe the TAP output that they will produce, showing any differences in description, directive, and diagnostics.

This is a procedural library.

FUNCTIONS ^

This module defines the following public functions:

plan( num_tests )

Sets the number of tests you plan to run, where num_tests is an int.

test_pass( test_string )

Sets the expectation for a test to pass. test_string is the optional description of the test.

test_fail( test_string )

Sets the expectation for a test to fail. test_string is the optional description of the test.

test_out( test_string )

Sets the expected output for this test to a string. This should be a line of TAP output containing a combination of test number, status, description, and directive.

test_err( test_string )

Sets the expected diagnostic output for this test to a string. This should be a line of TAP output containing a test directive.

test_diag( test_string )

Sets the expected diagnostic output for this test to a string. This should be a line of TAP output containing a test directive.

This and test_err() are effectively the same.

test_test( test_description )

Compares all of the expected test output and diagnostic output with the actual test output. This reports success or failure, using the giving string for the test description, and prints a diagnostic message with the divergent test output or diagnostic output.

AUTHOR ^

Written and maintained by chromatic, chromatic at wgz dot org, based on the Perl 6 port he wrote, based on the original Perl 5 version written by Mark Fowler. Please send patches, feedback, and suggestions to the Perl 6 internals mailing list.

COPYRIGHT ^

Copyright (c) 2005, the Perl Foundation.


parrot