From 3108b28dc1325b439a1f194ddba5ffa249ed32ee Mon Sep 17 00:00:00 2001 From: krakjoe Date: Thu, 5 Dec 2013 22:43:14 +0000 Subject: [PATCH] add format tests --- tests/commands/0102_print.test | 30 +++++++++--------- tests/run-tests.php | 57 +++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/tests/commands/0102_print.test b/tests/commands/0102_print.test index 6b19680361..be993de621 100644 --- a/tests/commands/0102_print.test +++ b/tests/commands/0102_print.test @@ -1,23 +1,23 @@ ################################################# # name: print # purpose: test print commands -# expect: TEST::CISTRING +# expect: TEST::FORMAT # options: -rr ################################################# -# Set execution context -# Attempting compilation -# Success -# User Class: test -# Methods (3): -# test::testMethod() -# ZEND_RETURN -# test::testPrivateMethod() -# ZEND_RETURN -# test::testProtectedMethod() -# ZEND_RETURN -# User Method testMethod -# test::testMethod() -# ZEND_RETURN +#[Set execution context: %s%eclass.php] +#[Attempting compilation of %s%eclass.php] +#[Success] +#[User Class: test] +#Methods (3): +#L%d-%d test::testMethod() %s%eclass.php +# L%d %s ZEND_RETURN C%d +# L%d-%d test::testPrivateMethod() %s%eclass.php +# L%d %s ZEND_RETURN C%d +# L%d-%d test::testProtectedMethod() %s%eclass.php +# L%d %s ZEND_RETURN C%d +#[User Method testMethod] +# L%d-%d test::testMethod() %s%eclass.php +# L%d %s ZEND_RETURN C%d ################################################# exec sapi/phpdbg/tests/code/class.php compile diff --git a/tests/run-tests.php b/tests/run-tests.php index 93ac6a7379..139ff93994 100644 --- a/tests/run-tests.php +++ b/tests/run-tests.php @@ -298,6 +298,11 @@ namespace phpdbg\testing { * Expect stripos() !== false */ const CISTRING = 0x00000100; + + /* + * Formatted output + */ + const FORMAT = 0x00001000; /** * Constructs a new Test object given a specilized phpdbginit file @@ -326,6 +331,9 @@ namespace phpdbg\testing { case 'TEST::CISTRING': case 'CISTRING': { $this->expect = TEST::CISTRING; } break; + case 'TEST::FORMAT': + case 'FORMAT': { $this->expect = TEST::FORMAT; } break; + default: throw new TestConfigurationException( $this->config, "unknown type of expectation (%s)", $chunks[1]); @@ -341,7 +349,46 @@ namespace phpdbg\testing { case '#': { /* do nothing */ } break; default: { - $this->match[] = ltrim(substr($trim, 1)); + $line = preg_replace( + "~(\r\n)~", "\n", substr($trim, 1)); + + $line = trim($line); + + switch ($this->expect) { + case TEST::FORMAT: + $this->match[] = str_replace(array( + '%e', + '%s', + '%S', + '%a', + '%A', + '%w', + '%i', + '%d', + '%x', + '%f', + '%c', + '%t', + '$T' + ), array( + '\\' . DIRECTORY_SEPARATOR, + '[^\r\n]+', + '[^\r\n]*', + '.+', + '.*', + '\s*', + '[+-]?\d+', + '\d+', + '[0-9a-fA-F]+', + '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', + '.', + '\t', + '\t+' + ), preg_quote($line)); + break; + + default: $this->match[] = $line; + } } } } break; @@ -406,6 +453,14 @@ namespace phpdbg\testing { $this->diff['gets'][$num] = $line; } } continue 2; + + case TEST::FORMAT: { + $line = trim($line); + if (!preg_match("/^{$this->match[$num]}\$/s", $line)) { + $this->diff['wants'][$num] = &$this->match[$num]; + $this->diff['gets'][$num] = $line; + } + } continue 2; } } } -- 2.50.1