in reply to Regex::Reverse tricky test cases

IMO you should use one of the various regex assembly modules, (grinders Regex::Assemble comes to mind) and see how your reversal code works on the output of that. It should be fairly simply to come up with a test framework that really hammers your reversal algorithm.

---
$world=~s/war/peace/g

Replies are listed 'Best First'.
Re^2: Regex::Reverse tricky test cases
by Roy Johnson (Monsignor) on May 17, 2005 at 14:11 UTC
    That's probably a good source for industrial-sized regexes, but the sticking point is: how do I know that what my program puts out is right? I don't have a lot of confidence in my ability to reverse them by hand, and even if I did, I'd only follow the same steps that my program does.

    I guess the best thing to do would be to generate a few strings that the regex will match, then also generate the reverse of the string and match against the reversed regex, then compare the captures.


    Caution: Contents may have been coded under pressure.

      I can't find your module. I can write tests for you, but not without access to your module and its interface.


      The Eightfold Path: 'use warnings;', 'use strict;', 'use diagnostics;', perltidy, CGI or CGI::Simple, try the CPAN first, big modules and small scripts, test first.

        As yet, it's not a module, it's just a program (and it almost certainly will not become a module, as the difficulties I had not recognized initially are substantial). It was not unexpected that I would find, once the real problems with reversal were pointed out, that they were over my head. But I wanted to understand the problem.

        If you are inclined to write tests for this, they would just be pairs: a regex and what it should reverse to.


        Caution: Contents may have been coded under pressure.