I'm building a regex helper at http://www.debuggex.com. The amount of detail I want to show requires me to write my own parser and matcher.
To make sure my parser and matcher work correctly, I've written my own unit tests for the Javascript flavor of regexes, but these only cover edge cases I know about. I would like to use a standard test suite, and was recently pointed to http://hg.ecmascript.org/tests/test262/summary, which I will be using.
My question is, where can I find such test suites for other regex flavors? I'd like to support other flavors in the future. I have not been able to find anything by googling ("test" pollutes the results with regex testers). I am looking for test suites for the languages python, php, perl, java, ruby, and .net.
Python is also a good language for regexes. They're not as easy to use as in Perl (the re library requires a little more verbosity), but the object-oriented approach avoids the pitfall that $1, $2, etc.
To test a regular expression, first search for errors such as non-escaped characters or unbalanced parentheses. Then test it against various input strings to ensure it accepts correct strings and regex wrong ones. A regex tester tool is a great tool that does all of this.
Tests should never depend on each other. If your tests have to be run in a specific order, then you need to change your tests. Instead, you should make proper use of the Setup and TearDown features of your unit-testing framework to ensure each test is ready to run individually.
Most of those languages are open source. Any decent project should have their test cases in said repo, otherwise I would be pretty concerned.
I also found an extensive chart on this page which might be of some help to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With