Rewrite HasPropertyWithValue to be a FeatureMatcher#96
Closed
tomwhoiscontrary wants to merge 0 commit intohamcrest:masterfrom
Closed
Rewrite HasPropertyWithValue to be a FeatureMatcher#96tomwhoiscontrary wants to merge 0 commit intohamcrest:masterfrom
tomwhoiscontrary wants to merge 0 commit intohamcrest:masterfrom
Conversation
6a67ddf to
5f79ba7
Compare
Author
|
I've taken this commit off my master so i can do other stuff. It's still around, on a different branch: |
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.
HasPropertyWithValue and FeatureMatcher look really similar to me, and it was driving me nuts that they're completely unrelated. So i made them related.
I have no idea if this is something you would actually want to merge, but i thought someone might at least find the idea mildly interesting.
Because FeatureMatcher has its own ideas about how mismatch descriptions look, i have changed the messages expected in the tests for HasPropertyWithValue. I think the new messages look at least as good as the old ones.
One source of complication in this was that FeatureMatcher::featureValueOf has no way to fail cleanly, so i introduced an Either-like type to wrap the extracted feature value (or its absence). This whole thing would be briefer and more idiomatic-for-Java if FeatureMatcher::featureValueOf was able to throw some sort of exception to signal that a feature's value could not be obtained. FeatureMatcher::matchesSafely could catch this and use its message as a mismatch description. This change would not be strictly backwards-compatible, but the only code which would suffer would be that calling FeatureMatcher::featureValueOf, which would be an odd thing to do.