Author: thebeing
Date: Wed Mar  9 16:38:32 2016
New Revision: 39506

URL: http://svn.gna.org/viewcvs/gnustep?rev=39506&view=rev
Log:
Implement -evaluateWithObject:substitutionVariables: (OS X 10.5 method),
and mark one of the GSBlockPredicate tests as hopeful on OS X.

Modified:
    libs/base/trunk/ChangeLog
    libs/base/trunk/Headers/Foundation/NSPredicate.h
    libs/base/trunk/Source/NSPredicate.m
    libs/base/trunk/Tests/base/NSPredicate/basic.m

Modified: libs/base/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/ChangeLog?rev=39506&r1=39505&r2=39506&view=diff
==============================================================================
--- libs/base/trunk/ChangeLog   (original)
+++ libs/base/trunk/ChangeLog   Wed Mar  9 16:38:32 2016
@@ -3,7 +3,8 @@
        * Headers/Foundation/NSPredicate.h
        * Source/NSPredicate.m
        * Tests/base/NSPredicate/basic.m:
-       Implementation and tests for +predicateWithBlock:
+       Implementation and tests for +predicateWithBlock: and
+       -evaluateWithObject:substitutionVariables:
 
 2016-03-09  Richard Frith-Macdonald <[email protected]>
 

Modified: libs/base/trunk/Headers/Foundation/NSPredicate.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Headers/Foundation/NSPredicate.h?rev=39506&r1=39505&r2=39506&view=diff
==============================================================================
--- libs/base/trunk/Headers/Foundation/NSPredicate.h    (original)
+++ libs/base/trunk/Headers/Foundation/NSPredicate.h    Wed Mar  9 16:38:32 2016
@@ -56,7 +56,11 @@
 - (NSString *) predicateFormat;
 - (NSPredicate *) predicateWithSubstitutionVariables:
   (GS_GENERIC_CLASS(NSDictionary,NSString*,id)*)variables;
-
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
+- (BOOL) evaluateWithObject: (id)object
+         substitutionVariables: 
+         (GS_GENERIC_CLASS(NSDictionary,NSString*,id)*)variables;
+#endif
 @end
 
 @interface NSArray (NSPredicate)

Modified: libs/base/trunk/Source/NSPredicate.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSPredicate.m?rev=39506&r1=39505&r2=39506&view=diff
==============================================================================
--- libs/base/trunk/Source/NSPredicate.m        (original)
+++ libs/base/trunk/Source/NSPredicate.m        Wed Mar  9 16:38:32 2016
@@ -360,6 +360,14 @@
   return AUTORELEASE([self copy]);  
 }
 
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
+- (BOOL) evaluateWithObject: (id)object
+         substitutionVariables: (GS_GENERIC_CLASS(NSDictionary, NSString*, 
id)*)variables
+{
+  return [[self predicateWithSubstitutionVariables: variables]
+                  evaluateWithObject: object];
+}
+#endif
 - (Class) classForCoder
 {
   return [NSPredicate class];
@@ -378,11 +386,12 @@
   return self;
 }
 
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
 + (NSPredicate*)predicateWithBlock: (GSBlockPredicateBlock)block
 {
   return [[[GSBlockPredicate alloc] initWithBlock: block] autorelease];
 }
-
+#endif
 @end
 
 @implementation GSTruePredicate

Modified: libs/base/trunk/Tests/base/NSPredicate/basic.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSPredicate/basic.m?rev=39506&r1=39505&r2=39506&view=diff
==============================================================================
--- libs/base/trunk/Tests/base/NSPredicate/basic.m      (original)
+++ libs/base/trunk/Tests/base/NSPredicate/basic.m      Wed Mar  9 16:38:32 2016
@@ -106,9 +106,11 @@
 testBlock(NSDictionary* dict)
 {
   START_SET("Block predicates");
+# if __has_feature(blocks)
   NSPredicate *p = nil;
   NSPredicate *p2 = nil;
-# if __has_feature(blocks)
+  NSDictionary *v = 
+    [NSDictionary dictionaryWithObjectsAndKeys: @"Record2", @"Key", nil];
   p = [NSPredicate predicateWithBlock: ^BOOL(id obj, NSDictionary *bindings)
     {
       NSString *key = [bindings objectForKey: @"Key"];
@@ -121,9 +123,22 @@
       return [value isEqualToString: @"John"];
     }];
   PASS([p evaluateWithObject: dict], "BLOCKPREDICATE() without bindings");
+  PASS(![p evaluateWithObject: dict 
+        substitutionVariables: v], "BLOCKPREDICATE() with bound variables");
   p2 = [p predicateWithSubstitutionVariables: 
     [NSDictionary dictionaryWithObjectsAndKeys: @"Record2", @"Key", nil]];
-  PASS(![p2 evaluateWithObject: dict], "BLOCKPREDICATE() with bound 
variables");
+  PASS(p2 != nil, "BLOCKPREDICATE() instantiated from template");
+# ifdef APPLE
+  /* The next test is known to be fail on OS X, so mark it as hopeful there. 
+   * cf. rdar://25059737
+   */
+  testHopeful = YES;
+# endif 
+  PASS(![p2 evaluateWithObject: dict], 
+    "BLOCKPREDICATE() with bound variables in separate object");
+# ifdef APPLE
+  testHopeful = NO;
+# endif
 #  else
   SKIP("No blocks support in the compiler.");
 #  endif


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to