mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Fix significant bug with storing composed matchers
Given that in the 2 or so years that matchers are thing nobody complained, it seems that people do not actually write this sort of code, and the possibility will be removed in v3. However, to avoid correctness bugs, we will have to support this weird code in v2.
This commit is contained in:
@@ -45,6 +45,34 @@ There should be no reason to ever have an empty `SourceLineInfo`, so the
|
||||
method will be removed.
|
||||
|
||||
|
||||
### Composing lvalues of already composed matchers
|
||||
|
||||
Because a significant bug in this use case has persisted for 2+ years
|
||||
without a bug report, and to simplify the implementation, code that
|
||||
composes lvalues of composed matchers will not compile. That is,
|
||||
this code will no longer work:
|
||||
|
||||
```cpp
|
||||
auto m1 = Contains("string");
|
||||
auto m2 = Contains("random");
|
||||
auto composed1 = m1 || m2;
|
||||
auto m3 = Contains("different");
|
||||
auto composed2 = composed1 || m3;
|
||||
REQUIRE_THAT(foo(), !composed1);
|
||||
REQUIRE_THAT(foo(), composed2);
|
||||
```
|
||||
|
||||
Instead you will have to write this:
|
||||
|
||||
```cpp
|
||||
auto m1 = Contains("string");
|
||||
auto m2 = Contains("random");
|
||||
auto m3 = Contains("different");
|
||||
REQUIRE_THAT(foo(), !(m1 || m2));
|
||||
REQUIRE_THAT(foo(), m1 || m2 || m3);
|
||||
```
|
||||
|
||||
|
||||
## Planned changes
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user