gpu: Tweak Android WebGL test expectations
[chromium-blink-merge.git] / third_party / ocmock / OCMock / OCMConstraint.m
blobe70e25981d47b0c1a773d5ce0ee98b8ff1fbffae
1 //---------------------------------------------------------------------------------------
2 //  $Id$
3 //  Copyright (c) 2007-2010 by Mulle Kybernetik. See License file for details.
4 //---------------------------------------------------------------------------------------
6 #import <OCMock/OCMConstraint.h>
9 @implementation OCMConstraint
11 + (id)constraint
13         return [[[self alloc] init] autorelease];
16 - (BOOL)evaluate:(id)value
18         return NO;
22 + (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject
24         OCMInvocationConstraint *constraint = [OCMInvocationConstraint constraint];
25         NSMethodSignature *signature = [anObject methodSignatureForSelector:aSelector]; 
26         if(signature == nil)
27                 [NSException raise:NSInvalidArgumentException format:@"Unkown selector %@ used in constraint.", NSStringFromSelector(aSelector)];
28         NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
29         [invocation setTarget:anObject];
30         [invocation setSelector:aSelector];
31         constraint->invocation = invocation;
32         return constraint;
35 + (id)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue
37         OCMInvocationConstraint *constraint = [self constraintWithSelector:aSelector onObject:anObject];
38         if([[constraint->invocation methodSignature] numberOfArguments] < 4)
39                 [NSException raise:NSInvalidArgumentException format:@"Constraint with value requires selector with two arguments."];
40         [constraint->invocation setArgument:&aValue atIndex:3];
41         return constraint;
45 @end
49 #pragma mark  -
51 @implementation OCMAnyConstraint
53 - (BOOL)evaluate:(id)value
55         return YES;
58 @end
62 #pragma mark  -
64 @implementation OCMIsNilConstraint
66 - (BOOL)evaluate:(id)value
68         return value == nil;
71 @end
75 #pragma mark  -
77 @implementation OCMIsNotNilConstraint
79 - (BOOL)evaluate:(id)value
81         return value != nil;
84 @end
88 #pragma mark  -
90 @implementation OCMIsNotEqualConstraint
92 - (BOOL)evaluate:(id)value
94         return ![value isEqual:testValue];
97 @end
101 #pragma mark  -
103 @implementation OCMInvocationConstraint
105 - (BOOL)evaluate:(id)value
107         [invocation setArgument:&value atIndex:2]; // should test if constraint takes arg
108         [invocation invoke];
109         BOOL returnValue;
110         [invocation getReturnValue:&returnValue];
111         return returnValue;
114 @end
116 #pragma mark  -
118 #if NS_BLOCKS_AVAILABLE
120 @implementation OCMBlockConstraint
122 - (id)initWithConstraintBlock:(BOOL (^)(id))aBlock;
124         self = [super init];
125         block = aBlock;
126         return self;
129 - (BOOL)evaluate:(id)value 
131         return block(value);
134 @end
136 #endif