NAME ^

Parrot::Test - testing routines for Parrot and language implementations

SYNOPSIS ^

Set the number of tests to be run like this:

    use Parrot::Test tests => 8;

Write individual tests like this:

    pasm_output_is(<<'CODE', <<'OUTPUT', "description of test");
    print "this is ok\n"
    end
    CODE
    this is ok
    OUTPUT

DESCRIPTION ^

This module provides various Parrot-specific test functions.

Functions ^

The parameter $language is the language of the code. The parameter $code is the code that should be executed or transformed. The parameter $expected is the expected result. The parameter $unexpected is the unexpected result. The parameter $description should describe the test.

Any optional parameters can follow. For example, to mark a test as a TODO test (where you know the implementation does not yet work), pass:

    todo => 'reason to consider this TODO'

at the end of the argument list. Valid reasons include bug, unimplemented, and so on.

Note: you must use a $description with TODO tests.

language_output_is( $language, $code, $expected, $description)

Runs a langugage test and passes the test if a string comparison of the output with the expected result it true.

language_output_like( $language, $code, $expected, $description)

Runs a langugage test and passes the test if the output matches the expected result.

language_output_isnt( $language, $code, $expected, $description)

Runs a langugage test and passes the test if a string comparison if a string comparison of the output with the unexpected result is false.

pasm_output_is($code, $expected, $description) or output_is($code, $expected, $description)

Runs the Parrot Assembler code and passes the test if a string comparison of the output with the expected result it true.

pasm_output_like($code, $expected, $description) or output_like($code, $expected, $description)

Runs the Parrot Assembler code and passes the test if the output matches the expected result.

pasm_output_isnt($code, $unexpected, $description) or output_isnt($code, $unexpected, $description)

Runs the Parrot Assembler code and passes the test if a string comparison of the output with the unexpected result is false.

past_output_is($code, $expected, $description)

Runs the PAST code and passes the test if a string comparison of output with the expected result is true.

past_output_like($code, $expected, $description)

Runs the PAST code and passes the test if output matches the expected result.

past_output_isnt($code, $unexpected, $description)

Runs the PAST code and passes the test if a string comparison of the output with the unexpected result is false.

pir_output_is($code, $expected, $description)

Runs the PIR code and passes the test if a string comparison of output with the expected result is true.

pir_output_like($code, $expected, $description)

Runs the PIR code and passes the test if output matches the expected result.

pir_output_isnt($code, $unexpected, $description)

Runs the PIR code and passes the test if a string comparison of the output with the unexpected result is false.

pbc_output_is($code, $expected, $description)

Runs the Parrot Bytecode and passes the test if a string comparison of output with the expected result is true.

pbc_output_like($code, $expected, $description)

Runs the Parrot Bytecode and passes the test if output matches the expected result.

pbc_output_isnt($code, $unexpected, $description)

Runs the Parrot Bytecode and passes the test if a string comparison of output with the unexpected result is false.

pir_2_pasm_is($code, $expected, $description)

Compile the Parrot Intermediate Representation and generate Parrot Assembler Code. Pass if the generated PASM is $expected.

pir_2_pasm_like($code, $expected, $description)

Compile the Parrot Intermediate Representation and generate Parrot Assembler Code. Pass if the generated PASM matches $expected.

pir_2_pasm_isnt($code, $unexpected, $description)

Compile the Parrot Intermediate Representation and generate Parrot Assembler Code. Pass unless the generated PASM is $expected.

c_output_is($code, $expected, $description, %options)

Compiles and runs the C code, passing the test if a string comparison of output with the expected result it true. Valid options are 'todo' => 'reason' to mark a TODO test.

c_output_like($code, $expected, $description, %options)

Compiles and runs the C code, passing the test if output matches the expected result. Valid options are 'todo' => 'reason' to mark a TODO test.

c_output_isnt($code, $unexpected, $description, %options)

Compiles and runs the C code, passing the test if a string comparison of output with the unexpected result is false. Valid options are 'todo' => 'reason' to mark a TODO test.

example_output_is( $example_f, $expected, @todo )

Determine the language from the extension of $example_f and runs language_output_is(). This does set a description for you, so don't pass one.

example_output_like( $example_f, $expected, @todo )

Determine the language from the extension of $example_f and runs language_output_like(). This does set a description for you, so don't pass one.

example_output_isnt( $example_f, $expected, @todo )

Determine the language from the extension of $example_f and runs language_output_isnt(). This does set a description for you, so don't pass one.

skip($why, $how_many)

Use within a SKIP: { ... } block to indicate why and how many tests to skip, just like in Test::More.

run_command($command, %options)

Run the given $command in a cross-platform manner.

%options include...

    STDOUT    filehandle to redirect STDOUT to
    STDERR    filehandle to redirect STDERR to
    CD        directory to run the command in
For example:

    # equivalent to "cd some_dir && make test"
    run_command("make test", CD => "some_dir");
slurp_file($file_name)

Read the whole file $file_name and return the content as a string.

convert_line_endings($text)

Convert Win32 style line endins with Unix style line endings.

path_to_parrot()

Construct a relative path from the current dir to the parrot root dir.

SEE ALSO ^

t/harness

docs/tests.pod

"More" in Test

"Builder" in Test


parrot