Writing Tests
As we
mentioned earlier, contributions to the Parrot project are welcome.
Contributing tests is a good place to start. You
don’t have to understand the code behind a PASM
opcode[44] to
test it, you only have to understand what it’s
supposed to do. If you’re working on some code and
it doesn’t do what the documentation advertises, you
can isolate the problem in a test or series of tests and send them to
the bug tracking system. There’s a good chance the
problem will be fixed before the next release. Writing tests makes it
a lot easier for the developer to know when they’ve
solved your problem—it’s solved when your
tests pass. It also prevents that problem from appearing again,
because it’s checked every time anyone runs
make
test
. As you move along,
you’ll want to write tests for every bug you fix or
new feature you add.
The Perl 5 testing framework is at the core of Parrot tests,
particularly
Test::Builder
.
Parrot’s
Parrot::Test
module is an interface to
Test::Builder
and implements the extra features
needed for testing Parrot, like the fact that PASM code has to be
compiled to bytecode before it runs.
The main Parrot tests are in the top-level t/
directory of the Parrot source tree. t/op
contains tests for basic opcodes and t/pmc
has
tests for PMCs. The names of the test files indicate the
functionality tested, like integer.t
,
number.t
, and string.t
.
Part of the make test
target is the command
perl t/harness
, which runs all the
.t
files in the subdirectories under ...
Get Perl 6 Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.