Repository navigation
fix!: fail a null subject for the negated form of an expectation - #1094
Merged
Merged
Conversation
`DoesNotComplyWith` negates an expectation, and a constraint that reports a null subject as a failure from its own `IsMetBy` has that failure flipped into a success - so `That(nullList).DoesNotComplyWith(x => x.HasItem(1))` passed, asserting that a collection which does not exist definitely has no such item. A null subject means the question is unanswerable, and inverting unanswerable gives unanswerable, not true. `ConstraintResult.WithNotNullValue<T>` already decides before the inversion is applied, which is why the 372 expectations built on it were right and these 45 were not. The ordering comparisons on a nullable number used the equality null policy, under which a null operand is legitimate. That reading belongs to `IsEqualTo`, not to `IsGreaterThan` - the same argument that moved `IsNotBetween` off `WithEqualToValue`, because neither a range nor an ordering has a null reading. The sweep only ever invoked the positive form, which is how this survived. `GuaranteesNotNullTests` now invokes every expectation through `DoesNotComplyWith` as well, and derives that axis' exemption rather than listing it: the negated form of an exempt expectation is exempt too, so `IsNotNull` negated is `IsNull`. `Exempt` stays the single source of truth for both axes. Five nested expectations are recorded as awaiting a core release. Their outer constraints already fail correctly on their own; only the composite does not, because the negation is applied by `MappingNode`, which cannot tell a subject that was ruled out as null from an expectation that was merely unmet. **BREAKING CHANGE:** a null subject now fails the negated form of every expectation that inspects it, and `Implies` reports `it was <null>` instead of `it did not`.
vbreuss
marked this pull request as ready for review
September 14, 2026 13:20
vbreuss
enabled auto-merge (squash)
September 14, 2026 13:21
vbreuss
disabled auto-merge
September 14, 2026 13:27
|
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
…ed form of an expectation (#1094) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Sep 14, 2026
…ed form of an expectation (#1094) by Valentin Breuß
Contributor
🚀 Benchmark ResultsDetails
|
Contributor
👽 Mutation ResultsaweXpectDetails
The final mutation score is 82.08%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


DoesNotComplyWithnegates an expectation, and a constraint that reports a null subject as a failure from its ownIsMetByhas that failure flipped into a success - soThat(nullList).DoesNotComplyWith(x => x.HasItem(1))passed, asserting that a collection which does not exist definitely has no such item. A null subject means the question is unanswerable, and inverting unanswerable gives unanswerable, not true.ConstraintResult.WithNotNullValue<T>already decides before the inversion is applied, which is why the 372 expectations built on it were right and these 45 were not.The ordering comparisons on a nullable number used the equality null policy, under which a null operand is legitimate. That reading belongs to
IsEqualTo, not toIsGreaterThan- the same argument that movedIsNotBetweenoffWithEqualToValue, because neither a range nor an ordering has a null reading.The sweep only ever invoked the positive form, which is how this survived.
GuaranteesNotNullTestsnow invokes every expectation throughDoesNotComplyWithas well, and derives that axis' exemption rather than listing it: the negated form of an exempt expectation is exempt too, soIsNotNullnegated isIsNull.Exemptstays the single source of truth for both axes.Five nested expectations are recorded as awaiting a core release. Their outer constraints already fail correctly on their own; only the composite does not, because the negation is applied by
MappingNode, which cannot tell a subject that was ruled out as null from an expectation that was merely unmet.BREAKING CHANGE:
a null subject now fails the negated form of every expectation that inspects it, and
Impliesreportsit was <null>instead ofit did not.