]> granicus.if.org Git - php/commitdiff
add format tests
authorkrakjoe <joe.watkins@live.co.uk>
Thu, 5 Dec 2013 22:43:14 +0000 (22:43 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Thu, 5 Dec 2013 22:43:14 +0000 (22:43 +0000)
tests/commands/0102_print.test
tests/run-tests.php

index 6b19680361985648fbe9d1cffcf6bfec854074e1..be993de621d11a5a55cded1132b2adde54375344 100644 (file)
@@ -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
index 93ac6a7379825d73ed2a294bb164376e81636ce2..139ff9399457cc5450a569c74affe8ed9ce53d04 100644 (file)
@@ -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;
                                        }
                                }
                        }