regular expression in test output (new feature for run-tests.php)

From: Date: Wed, 04 Feb 2009 17:34:33 +0000
Subject: regular expression in test output (new feature for run-tests.php)
Groups: php.qa 
Request: Send a blank email to php-qa+get-64639@lists.php.net to get a copy of this message
Hi all, I have been writing some tests recently, and occasionally thought it would be useful to use a regex for output matching. However, using the --EXPECTREGEX-- can be a bit painful as you sometimes have to escape a large number of characters. I think it would be really useful to add a new specifier to the EXPECTF section that would allow you to embed a small regex in the output. If you used say %r as an opening and closing tag you could then do something like (for a very trivial example): --TEST-- Testing host --FILE-- <?php echo "host name is " . gethostbyname("example.com"); ?> --EXPECTF-- host name is %r\d\d\d\.\d\d\d.\d\d\d.\d\d\d%r This allows you to write a test which is a bit more specific about what it is expecting, and hopefully less prone to false positives. What does anyone think? I've spoken to Zoe about this and she is happy to try and implement it if people are interested.

« previous php.qa (#64639) next »