develooper Front page | perl.perl6.compiler | Postings from November 2004

P6GE tests wanted

Thread Next
Patrick R. Michaud
November 20, 2004 15:10
P6GE tests wanted
Message ID:
Okay, with help from Jared Rhine I've got a simple testing framework in
place for p6ge, now we could use some contributed tests.  I've also
updated the code with suggestions contributed by others.

The testing framework is based on Parrot::Test, it introduces three
new testing functions which are roughly analogous to their equivalents
in Parrot::Test:

    p6rule_is($target, $pattern, $description)
    p6rule_isnt($target, $pattern, $description)
    p6rule_like($target, $pattern, $expected, $description)

Thus, one can do the following for testing if a pattern should
or should not match:

    p6rule_is('abc', '^abc', 'beg of string abc');
    p6rule_isnt('abc', '^bc', 'beg of string bc');

Note that the pattern to be used it the second argument (think of it
as being in the same order as P5's  $text =~ /pattern/  expression),
and that it has to be specified as a string with no delimiters.

The p6rule_like() function will be used to test side-effects or
optimizations in the string.  For example, to see $0 and $1 are 
correctly captured:

    p6rule_like('xxxa(bc)dxxx', 'abcd', 
                qr/0: <abcd @ 3>/, '$0 capture');
    p6rule_like('xxxa(bc)dxxx', 'abcd', 
                qr/1: <bc @ 4>/, '$1 capture');

which says that $0 was captured as string 'abcd' starting at position 3.

There are a couple of example test scripts in the t/p6rules directory
that can be used as a model.

I know there are lots of existing regular expression test suites out
there, so if others could convert the relevant portions to work with the 
above framework, that'd be great.  Also note that so far p6ge only 
implements the basic regular expression constructs -- so if a 
particular test fails it might simply be because p6ge doesn't implement it
yet.  (Don't let that stop you from entering a test into the suite, 
just be sure to mark it as TODO: so we aren't dealing with lots of 
failed tests.)

Thanks, I'll have more updates in another day or so.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About