Skip to content

Commit 1618997

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Support more placeholders in bless_tests.php
2 parents 3e14942 + ababa22 commit 1618997

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scripts/dev/bless_tests.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,15 @@ function normalizeOutput(string $out): string {
7777

7878
function 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

107114
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) {
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

Comments
 (0)