mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Support more placeholders in bless_tests.php
And don't replace trailing --CLEAN-- sections.
This commit is contained in:
parent
5a201ddad0
commit
ababa22136
1 changed files with 10 additions and 3 deletions
|
@ -77,8 +77,15 @@ function normalizeOutput(string $out): string {
|
||||||
|
|
||||||
function formatToRegex(string $format): string {
|
function formatToRegex(string $format): string {
|
||||||
$result = preg_quote($format, '/');
|
$result = preg_quote($format, '/');
|
||||||
$result = str_replace('%d', '\d+', $result);
|
$result = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $result);
|
||||||
$result = str_replace('%s', '[^\r\n]+', $result);
|
$result = str_replace('%s', '[^\r\n]+', $result);
|
||||||
|
$result = str_replace('%S', '[^\r\n]*', $result);
|
||||||
|
$result = str_replace('%w', '\s*', $result);
|
||||||
|
$result = str_replace('%i', '[+-]?\d+', $result);
|
||||||
|
$result = str_replace('%d', '\d+', $result);
|
||||||
|
$result = str_replace('%x', '[0-9a-fA-F]+', $result);
|
||||||
|
$result = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $result);
|
||||||
|
$result = str_replace('%c', '.', $result);
|
||||||
return "/^$result$/s";
|
return "/^$result$/s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,10 +112,10 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertOutput(string $phpt, string $out): string {
|
function insertOutput(string $phpt, string $out): string {
|
||||||
return preg_replace_callback('/--EXPECTF?--.*$/s', function($matches) use($out) {
|
return preg_replace_callback('/--EXPECTF?--.*?(--CLEAN--|$)/sD', function($matches) use($out) {
|
||||||
$hasWildcard = preg_match('/%[resSaAwidxfc]/', $out);
|
$hasWildcard = preg_match('/%[resSaAwidxfc]/', $out);
|
||||||
$F = $hasWildcard ? 'F' : '';
|
$F = $hasWildcard ? 'F' : '';
|
||||||
return "--EXPECT$F--\n" . $out . "\n";
|
return "--EXPECT$F--\n" . $out . "\n" . $matches[1];
|
||||||
}, $phpt);
|
}, $phpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue