Skip to content

Commit f19334f

Browse files
Closes #5979
1 parent 690a1f7 commit f19334f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

ChangeLog-10.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi
88

99
* [#5957](https://github.com/sebastianbergmann/phpunit/pull/5957): Skip data provider build when requirements are not satisfied
1010
* [#5969](https://github.com/sebastianbergmann/phpunit/pull/5969): Check for requirements before creating a separate process
11+
* Updated regular expressions used by `StringMatchesFormatDescription` constraint to be consistent with PHP's `run-tests.php`
1112

1213
### Fixed
1314

src/Framework/Constraint/String/StringMatchesFormatDescription.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,18 @@ private function regularExpressionForFormatDescription(string $string): string
8787
preg_quote($string, '/'),
8888
[
8989
'%%' => '%',
90-
'%e' => '\\' . DIRECTORY_SEPARATOR,
90+
'%e' => preg_quote(DIRECTORY_SEPARATOR, '/'),
9191
'%s' => '[^\r\n]+',
9292
'%S' => '[^\r\n]*',
93-
'%a' => '.+',
94-
'%A' => '.*',
93+
'%a' => '.+?',
94+
'%A' => '.*?',
9595
'%w' => '\s*',
9696
'%i' => '[+-]?\d+',
9797
'%d' => '\d+',
9898
'%x' => '[0-9a-fA-F]+',
99-
'%f' => '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?',
99+
'%f' => '[+-]?(?:\d+|(?=\.\d))(?:\.\d+)?(?:[Ee][+-]?\d+)?',
100100
'%c' => '.',
101+
'%0' => '\x00',
101102
],
102103
);
103104

tests/unit/Framework/Constraint/String/StringMatchesFormatDescriptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ public function testConstraintStringMatchesFloat(): void
141141
$this->assertFalse($constraint->evaluate('**', '', true));
142142
$this->assertFalse($constraint->evaluate('***', '', true));
143143
$this->assertFalse($constraint->evaluate('*a*', '', true));
144+
$this->assertFalse($constraint->evaluate('*1.*', '', true));
144145

145146
$this->assertTrue($constraint->evaluate('*1.0*', '', true));
146147
$this->assertTrue($constraint->evaluate('*0*', '', true));
147148
$this->assertTrue($constraint->evaluate('*12*', '', true));
148149
$this->assertTrue($constraint->evaluate('*.1*', '', true));
149-
$this->assertTrue($constraint->evaluate('*1.*', '', true));
150150
$this->assertTrue($constraint->evaluate('*2e3*', '', true));
151151
$this->assertTrue($constraint->evaluate('*-2.34e-56*', '', true));
152152
$this->assertTrue($constraint->evaluate('*+2.34e+56*', '', true));

0 commit comments

Comments
 (0)