@@ -77,8 +77,15 @@ function normalizeOutput(string $out): string {
7777
7878function formatToRegex (string $ format ): string {
7979 $ result = preg_quote ($ format , '/ ' );
80- $ result = str_replace ('%d ' , '\d+ ' , $ result );
80+ $ result = str_replace ('%e ' , '\\' . DIRECTORY_SEPARATOR , $ result );
8181 $ result = str_replace ('%s ' , '[^\r\n]+ ' , $ result );
82+ $ result = str_replace ('%S ' , '[^\r\n]* ' , $ result );
83+ $ result = str_replace ('%w ' , '\s* ' , $ result );
84+ $ result = str_replace ('%i ' , '[+-]?\d+ ' , $ result );
85+ $ result = str_replace ('%d ' , '\d+ ' , $ result );
86+ $ result = str_replace ('%x ' , '[0-9a-fA-F]+ ' , $ result );
87+ $ result = str_replace ('%f ' , '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)? ' , $ result );
88+ $ result = str_replace ('%c ' , '. ' , $ result );
8289 return "/^ $ result$/s " ;
8390}
8491
@@ -105,10 +112,10 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
105112}
106113
107114function insertOutput (string $ phpt , string $ out ): string {
108- return preg_replace_callback ('/--EXPECTF?--.*$/s ' , function ($ matches ) use ($ out ) {
115+ return preg_replace_callback ('/--EXPECTF?--.*?(--CLEAN--|$)/sD ' , function ($ matches ) use ($ out ) {
109116 $ hasWildcard = preg_match ('/%[resSaAwidxfc]/ ' , $ out );
110117 $ F = $ hasWildcard ? 'F ' : '' ;
111- return "--EXPECT $ F-- \n" . $ out . "\n" ;
118+ return "--EXPECT $ F-- \n" . $ out . "\n" . $ matches [ 1 ] ;
112119 }, $ phpt );
113120}
114121
0 commit comments