Categories

Posts in this category

Tue, 11 May 2010

This Week's Contribution to Perl 6 Week 2: Fix up a test


Permanent link

For this week's contribution to Perl 6 we ask you to fix a short test file in the official spec tests.

(Introduction to this series of challenges)

Background

The test file in S05-grammar/parse_and_parsefile.t tests the.parse and .parsefile methods of custom grammars.

However, it uses the outdated assumption that Grammar.parse automatically searches for a match in a string, just like a regex match does. That's not the case anymore; The current specification says that .parse is anchored to the beginning and end of the string, which means it always parses the entire string, or nothing at all.

What you can do

Update the test file to reflect the current specification, so that the parse and parsefile methods match the whole test string.

In the old version the test made sure that only the correct submatch was found; please replace that by a test for a non-matching grammar or test string.

The Rakudo Perl 6 compiler implements the parse and parsefile method. Please run your test file on Rakudo, and make sure it runs on Rakudo. Bonus points if you can finde a bug in Rakudo's parse or parsefile methods, and add another test that demonstrates the bug. (Disclaimer: I have no knowledge of such a bug; there might not be one at all).

Submission

<update> bubaflub has taken the challenge, and fixed the test in r30617. Of course further improvements to the test are still welcome.</update>.

For this challenge please join the #perl6 IRC channel, and ask for a commit bit to the test suite. You'll need to tell us your desired nick name and email address for the SVN user account.

When you build Rakudo by following these instructions, run make spectest. This will automatically checkout out a copy of the test into the t/spec subdirectory of your rakudo directory.

Edit t/spec/S05-grammar/parse_and_parsefile.t, and then test it by running

make t/spec/S05-grammar/parse_and_parsefile.t
# if you need more diagnostic output, also run
./perl6 t/spec/S05-grammar/parse_and_parsefile.rakudo

Once you have the test file passing and correct, change to the t/spec directory, and commit your changes:

svn ci -m '[t/spec] bring parse_and_parsefile.t up to date' S05-grammar/parse_and_parsefile.t

If you need any guidance, please don't hesitate to ask us either on IRC, or through the perl6-compiler@perl.org mailing list.

[/perl-6] Permanent link