mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
NSPredicate Value Fix
* Check if object is an NSExpression object * Fix Indentation * Update Changelog * Add test case
This commit is contained in:
parent
68f6862ff2
commit
7fd20d1ae3
3 changed files with 25 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
2022-08-16 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Source/NSPredicate.m:
|
||||
When parsing an NSArray in -expressionValueWithObject:context:,
|
||||
check if the array entry is a NSExpression object.
|
||||
* Tests/base/NSPredicate/basic.m:
|
||||
Test filter operation.
|
||||
|
||||
2022-08-16 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Source/win32/GSFileHandle.m:
|
||||
|
|
|
@ -1374,8 +1374,18 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
|
||||
while (index < count)
|
||||
{
|
||||
NSExpression *e = [(NSArray*)_obj objectAtIndex: index++];
|
||||
id o = [e expressionValueWithObject: e context: context];
|
||||
id e = [(NSArray*)_obj objectAtIndex: index++];
|
||||
id o;
|
||||
|
||||
/* Array index is not always a NSExpression object
|
||||
* (e.g. When specified as an argument instead of
|
||||
* an inline expression).
|
||||
*/
|
||||
if ([e isKindOfClass: [NSExpression class]]) {
|
||||
o = [e expressionValueWithObject: e context: context];
|
||||
} else {
|
||||
o = e;
|
||||
}
|
||||
|
||||
[tmp addObject: o];
|
||||
}
|
||||
|
|
|
@ -250,6 +250,11 @@ int main()
|
|||
p = [NSPredicate predicateWithFormat: @"sum(a) == 3"];
|
||||
PASS([p evaluateWithObject: a], "aggregate sum works");
|
||||
|
||||
p = [NSPredicate predicateWithFormat: @"self IN %@", @[@"yes"]];
|
||||
a = [@[@"yes", @"no"] filteredArrayUsingPredicate: p];
|
||||
PASS_EQUAL([a description], @"(yes)",
|
||||
"predicate created with format can filter an array")
|
||||
|
||||
END_SET("basic")
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue