Test::More - Parrot extension for testing modules


        # load this library
        load_bytecode 'library/Test/More.pir'

        # get the testing functions
        .local pmc plan
        .local pmc ok
        .local pmc is

        plan = find_global 'Test::More', 'plan'
        ok   = find_global 'Test::More',   'ok'
        is   = find_global 'Test::More',   'is'

        # set a test plan
        plan( 10 )

        # run your tests
        ok( 1 )
        ok( 0, 'failing test with diagnostic' )

        is( 100, 100 )
        is( 200, 100, 'failing integer compare with diagnostic' )

        is( 1.001, 1.001, 'passing float compare with diagnostic' )
        is( 8.008, 4.004 )

        is( 'foo', 'foo', 'passing string compare with diagnostic' )
        is( 'foo', 'bar', 'failing string compare with diagnostic' )

        is( some_pmc, another_pmc, 'pmc comparison uses "eq" op' )


Test::More is a pure-Parrot library for testing modules. It provides the ok() and is() functions for you. It uses Test::Builder, a simple, single backend for multiple test modules to use within your tests.


This class defines the following functions:

plan( number_or_no_plan )

Declares the number of tests you plan to run, either an integer greater than zero or the string no_plan. This will throw an exception if you have already declared a plan or if you pass an invalid argument.

ok( passed, description )

Records a test as pass or fail depending on the truth of the integer passed, recording it with the optional test description in description.

is( left, right, description )

Compares the parameters passed as left and right, passing if they are equal and failing otherwise. This will report the results with the optional test description in description.

This is a multi-method, with separate implementations for int-int, float-float, string-string, and PMC-PMC comparisons. The latter uses the eq opcode for comparison.

This probably doesn't handle all of the comparisons you want, but it's easy to add more.


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 he wrote with ideas from Michael G. Schwern. Please send patches, feedback, and suggestions to the Perl 6 internals mailing list.


Copyright (c) 2005, the Perl Foundation.