@@ -77,8 +77,15 @@ function normalizeOutput(string $out): string {
77
77
78
78
function formatToRegex (string $ format ): string {
79
79
$ result = preg_quote ($ format , '/ ' );
80
- $ result = str_replace ('%d ' , '\d+ ' , $ result );
80
+ $ result = str_replace ('%e ' , '\\' . DIRECTORY_SEPARATOR , $ result );
81
81
$ 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 );
82
89
return "/^ $ result$/s " ;
83
90
}
84
91
@@ -105,10 +112,10 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
105
112
}
106
113
107
114
function 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 ) {
109
116
$ hasWildcard = preg_match ('/%[resSaAwidxfc]/ ' , $ out );
110
117
$ F = $ hasWildcard ? 'F ' : '' ;
111
- return "--EXPECT $ F-- \n" . $ out . "\n" ;
118
+ return "--EXPECT $ F-- \n" . $ out . "\n" . $ matches [ 1 ] ;
112
119
}, $ phpt );
113
120
}
114
121
0 commit comments