com php-src: add format tests: tests/commands/0102_pr int.test tests/run-tests.php
| From: | Bob Weinand | Date: | Thu, 05 Dec 2013 22:43:14 +0000 |
| Subject: | com php-src: add format tests: tests/commands/0102_pr int.test tests/run-tests.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75293@lists.php.net to get a copy of this message | ||
Commit: 3108b28dc1325b439a1f194ddba5ffa249ed32ee
Author: krakjoe <joe.watkins@live.co.uk> Thu, 5 Dec 2013 22:43:14 +0000
Parents: 35bf23355069fe957a8d57dca7b82429a68589d4
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3108b28dc1325b439a1f194ddba5ffa249ed32ee
Log:
add format tests
Changed paths:
M tests/commands/0102_print.test
M tests/run-tests.php
Diff:
diff --git a/tests/commands/0102_print.test b/tests/commands/0102_print.test
index 6b19680..be993de 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 <unused>
<unused>
+# L%d-%d test::testPrivateMethod() %s%eclass.php
+# L%d %s ZEND_RETURN C%d <unused>
<unused>
+# L%d-%d test::testProtectedMethod() %s%eclass.php
+# L%d %s ZEND_RETURN C%d <unused>
<unused>
+#[User Method testMethod]
+# L%d-%d test::testMethod() %s%eclass.php
+# L%d %s ZEND_RETURN C%d <unused>
<unused>
#################################################
exec sapi/phpdbg/tests/code/class.php
compile
diff --git a/tests/run-tests.php b/tests/run-tests.php
index 93ac6a7..139ff93 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;
}
}
}