-
Notifications
You must be signed in to change notification settings - Fork 214
Fix bounds ordering for captured Range values in Predicate to NSPredicate conversion #1640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| // Verify that if bounds were swapped, the predicate would be wrong | ||
| // (This would be i >= upperDate AND i < lowerDate, which is always false) | ||
| let wrongPredicate = NSPredicate(format: "i >= %@ AND i < %@", upperDate as NSDate, lowerDate as NSDate) | ||
| #expect(!wrongPredicate.evaluate(with: objInRange), "Swapped bounds would incorrectly reject valid date") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What benefit did you find with adding this additional test? Is it testing Predicate to NSPredicate conversion in some way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It proves the ordering of bounds matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on what you mean by that? I don't fully understand what this is proving here regarding the conversion code that you updated. It doesn't look like this code goes through the Predicate/NSPredicate conversion code but instead looks like it's just testing NSPredicate itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It exercises the _RangeValue conversion path for captured ranges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks that when extracting bounds from a captured Range (via range.lowerBound and range.upperBound at line 326), they are used in the correct order when building the NSPredicate (lower for >=, upper for <).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But yeah the last two parts are redundant.
556e32b to
c7fbf09
Compare
…cate conversion We seem to be passing upper to lower and lower to upper when converting. That does not seem right.
|
@swift-ci please test |
We seem to be passing upper to lower and lower to upper when converting. That does not seem right.