@@ -24,7 +24,7 @@ @implementation OCMArg
24
24
25
25
+ (id )any
26
26
{
27
- return [[[OCMAnyConstraint alloc ] init ] autorelease ];
27
+ return [self anyWithOptions: OCMArgDefaultOptions ];
28
28
}
29
29
30
30
+ (void *)anyPointer
@@ -44,39 +44,79 @@ + (SEL)anySelector
44
44
45
45
+ (id )isNil
46
46
{
47
- return [OCMIsNilConstraint constraint ];
47
+ return [self isNilWithOptions: OCMArgDefaultOptions ];
48
48
}
49
49
50
50
+ (id )isNotNil
51
51
{
52
- return [OCMIsNotNilConstraint constraint ];
52
+ return [self isNotNilWithOptions: OCMArgDefaultOptions ];
53
53
}
54
54
55
55
+ (id )isEqual : (id )value
56
56
{
57
- return [[[OCMIsEqualConstraint alloc ] initWithTestValue : value] autorelease ];
57
+ return [self isEqual : value options: OCMArgDefaultOptions ];
58
58
}
59
59
60
60
+ (id )isNotEqual : (id )value
61
61
{
62
- return [[[OCMIsNotEqualConstraint alloc ] initWithTestValue : value] autorelease ];
62
+ return [self isNotEqual : value options: OCMArgDefaultOptions ];
63
63
}
64
64
65
65
+ (id )isKindOfClass : (Class )cls
66
66
{
67
- return [[[OCMBlockConstraint alloc ] initWithConstraintBlock: ^BOOL (id obj) {
68
- return [obj isKindOfClass: cls];
69
- }] autorelease ];
67
+ return [self isKindOfClass: cls options: OCMArgDefaultOptions];
70
68
}
71
69
72
70
+ (id )checkWithSelector : (SEL )selector onObject : (id )anObject
73
71
{
74
- return [OCMConstraint constraintWithSelector : selector onObject: anObject];
72
+ return [self checkWithSelector : selector onObject: anObject options: OCMArgDefaultOptions ];
75
73
}
76
74
77
75
+ (id )checkWithBlock : (BOOL (^)(id ))block
78
76
{
79
- return [[[OCMBlockConstraint alloc ] initWithConstraintBlock: block] autorelease ];
77
+ return [self checkWithOptions: OCMArgDefaultOptions withBlock: block];
78
+ }
79
+
80
+ + (id )anyWithOptions : (OCMArgOptions)options
81
+ {
82
+ return [[[OCMAnyConstraint alloc ] initWithOptions: [self constraintOptionsFromArgOptions: options]] autorelease ];
83
+ }
84
+
85
+ + (id )isNilWithOptions : (OCMArgOptions)options
86
+ {
87
+ return [[[OCMIsEqualConstraint alloc ] initWithTestValue: nil options: [self constraintOptionsFromArgOptions: options]] autorelease ];
88
+ }
89
+
90
+ + (id )isNotNilWithOptions : (OCMArgOptions)options
91
+ {
92
+ return [[[OCMIsNotEqualConstraint alloc ] initWithTestValue: nil options: [self constraintOptionsFromArgOptions: options]] autorelease ];
93
+ }
94
+
95
+ + (id )isEqual : (id )value options : (OCMArgOptions)options
96
+ {
97
+ return [[[OCMIsEqualConstraint alloc ] initWithTestValue: value options: [self constraintOptionsFromArgOptions: options]] autorelease ];
98
+ }
99
+
100
+ + (id )isNotEqual : (id )value options : (OCMArgOptions)options
101
+ {
102
+ return [[[OCMIsNotEqualConstraint alloc ] initWithTestValue: value options: [self constraintOptionsFromArgOptions: options]] autorelease ];
103
+ }
104
+
105
+ + (id )isKindOfClass : (Class )cls options : (OCMArgOptions)options
106
+ {
107
+ return [[[OCMBlockConstraint alloc ] initWithOptions: [self constraintOptionsFromArgOptions: options] block: ^BOOL (id obj) {
108
+ return [obj isKindOfClass: cls];
109
+ }] autorelease ];
110
+ }
111
+
112
+ + (id )checkWithSelector : (SEL )selector onObject : (id )anObject options : (OCMArgOptions)options
113
+ {
114
+ return [OCMConstraint constraintWithSelector: selector onObject: anObject options: [self constraintOptionsFromArgOptions: options]];
115
+ }
116
+
117
+ + (id )checkWithOptions : (OCMArgOptions)options withBlock : (BOOL (^)(id obj))block
118
+ {
119
+ return [[[OCMBlockConstraint alloc ] initWithOptions: [self constraintOptionsFromArgOptions: options] block: block] autorelease ];
80
120
}
81
121
82
122
+ (id *)setTo : (id )value
@@ -141,4 +181,13 @@ + (id)resolveSpecialValues:(NSValue *)value
141
181
return value;
142
182
}
143
183
184
+ + (OCMConstraintOptions)constraintOptionsFromArgOptions : (OCMArgOptions)argOptions
185
+ {
186
+ OCMConstraintOptions constraintOptions = 0 ;
187
+ if (argOptions & OCMArgDoNotRetainStubArg) constraintOptions |= OCMConstraintDoNotRetainStubArg;
188
+ if (argOptions & OCMArgDoNotRetainInvocationArg) constraintOptions |= OCMConstraintDoNotRetainInvocationArg;
189
+ if (argOptions & OCMArgCopyInvocationArg) constraintOptions |= OCMConstraintCopyInvocationArg;
190
+ return constraintOptions;
191
+ }
192
+
144
193
@end
0 commit comments