Garrett Goebel wrote:

> Can anyone write up a detailed document describing how one would go about
> writing Perl6 test cases and submitting them to Parrot? The parrot
> documentation on testing, is understandably focused on testing parrot...
> not the languages running on parrot.
> 
> I can't find any writeup or overview on the Perl5 regression test
> framework. Which is odd, because I'd expect something like that to exist
> in the core documentation. -Perhaps I'm just missing it...

I'm not going to attempt the "detailed" document you ask for; but I would
like to offer some thoughts.

Test suites for Perl5 modules can be somewhat opaque. It is not obvious
what is being tested. Anyone familiar with "Agile" programming methods
will know the importance of good tests is; and that test-code should
be as well written as actual production code. We should attempt to set
a good example.

It is often hard to write good tests. Especially if they are written
as a derivative of a spec (or, Argh, of the code itself). Writing tests
should be one of the most important activities of any module writer,
so we should want it to be one of the easiest things that one can do
in Perl6.

Making things easy, is hard!

So we should be prepared to endure some pain to get it write. We should
expect to implement some tests in one way, then throw them out (or
convert them) when we find a better way. We MUST avoid setting our
testing approach in stone from Day-1.

We probably want to orient towards something like the xUnit test-suites;
but we want to do it in a way that incorporates a module's documentation
(the module in question may be CORE:: -- so lets not think of the
Perl6 documentation project as a special case).

I've just said we should expect to thouw away tests, when we find better
ways of doing things; so here's one to throw away:


=chapter 0 Getting Started

Every programming book starts with a simple program that prints the message 
"hello, world" to the screen. The Perl6 documentation is no exception. This 
is how to write this simple program in Perl6:

=test-src hello_world

print "hello, world\n";

=explaination
When you run this program, you should see the message on the screen

=test-stdout
hello, world
=test-end


OK, so its a trivial test; but we must be able to write them. We'll find
various problems with alternative output devices, etc.; but this shouldn't 
put us off.

The emphesis in on using a test to explore a behaviour, from the perspective 
of a user. It is not a white-box test. The test should be readable as part 
of the documentation: not something separate, that only gurus can fathom. 
We need a standard script that runs tests that are embedded in 
documentation.


Dave.

Reply via email to