Skip to content

Commit 461c694

Browse files
committed
Renamed method to avoid clashes.
This is an alternative to #429. Note that I removed the setting of the flag in `doesNotRecognizeSelector:`. This seemed superfluous now because the only code that checks the flag first checks whether the invocation threw. Because of that I chose the name didRecord, and not didReceive. The latter would have been more precise if I had kept the setting of the flag in `doesNotRecognizeSelector:`. I am aware that using a prefix would have decreased chances of a clash even further, but I think this is good enough and it's more consistent with the rest of the codebase for now.
1 parent e9e61d1 commit 461c694

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

Source/OCMock/OCMMacroState.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ + (OCMStubRecorder *)endStubMacro
4040
OCMStubRecorder *recorder = [[(OCMStubRecorder *)[globalState recorder] retain] autorelease];
4141
BOOL didThrow = [globalState invocationDidThrow];
4242
[threadDictionary removeObjectForKey:OCMGlobalStateKey];
43-
if(didThrow == NO && [recorder wasUsed] == NO)
43+
if(didThrow == NO && [recorder didRecordInvocation] == NO)
4444
{
4545
[NSException raise:NSInternalInconsistencyException
4646
format:@"Did not record an invocation in OCMStub/OCMExpect/OCMReject.\n"
@@ -106,7 +106,7 @@ + (void)endVerifyMacro
106106
OCMVerifier *verifier = [[(OCMVerifier *)[globalState recorder] retain] autorelease];
107107
BOOL didThrow = [globalState invocationDidThrow];
108108
[threadDictionary removeObjectForKey:OCMGlobalStateKey];
109-
if(didThrow == NO && [verifier wasUsed] == NO)
109+
if(didThrow == NO && [verifier didRecordInvocation] == NO)
110110
{
111111
[NSException raise:NSInternalInconsistencyException
112112
format:@"Did not record an invocation in OCMVerify.\n"

Source/OCMock/OCMObserverRecorder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929

3030
- (BOOL)argument:(id)expectedArg matchesArgument:(id)observedArg;
3131

32-
- (BOOL)wasUsed;
32+
- (BOOL)didRecordInvocation __used;
3333

3434
@end

Source/OCMock/OCMObserverRecorder.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ - (void)dealloc
3838
[super dealloc];
3939
}
4040

41-
- (BOOL)wasUsed
41+
- (BOOL)didRecordInvocation
4242
{
4343
return YES; // Needed for macro use, and recorder can only end up in macro state if it was used.
4444
}

Source/OCMock/OCMRecorder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
{
2525
OCMockObject *mockObject;
2626
OCMInvocationMatcher *invocationMatcher;
27-
BOOL wasUsed;
27+
BOOL didRecordInvocation;
2828
BOOL shouldReturnMockFromInit;
2929
}
3030

@@ -36,7 +36,7 @@
3636
- (void)setShouldReturnMockFromInit:(BOOL)flag;
3737

3838
- (OCMInvocationMatcher *)invocationMatcher;
39-
- (BOOL)wasUsed;
39+
- (BOOL)didRecordInvocation;
4040

4141
- (id)classMethod;
4242
- (id)ignoringNonObjectArgs;

Source/OCMock/OCMRecorder.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ @implementation OCMRecorder
2727
- (instancetype)init
2828
{
2929
// no super, we're inheriting from NSProxy
30-
wasUsed = NO;
30+
didRecordInvocation = NO;
3131
shouldReturnMockFromInit = NO;
3232
return self;
3333
}
@@ -65,9 +65,9 @@ - (OCMInvocationMatcher *)invocationMatcher
6565
return invocationMatcher;
6666
}
6767

68-
- (BOOL)wasUsed
68+
- (BOOL)didRecordInvocation
6969
{
70-
return wasUsed;
70+
return didRecordInvocation;
7171
}
7272

7373

@@ -111,7 +111,7 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
111111
- (void)forwardInvocation:(NSInvocation *)anInvocation
112112
{
113113
[anInvocation setTarget:nil];
114-
wasUsed = YES;
114+
didRecordInvocation = YES;
115115
[invocationMatcher setInvocation:anInvocation];
116116

117117
// Code with ARC may retain the receiver of an init method before invoking it. In that case it
@@ -128,7 +128,6 @@ - (void)forwardInvocation:(NSInvocation *)anInvocation
128128

129129
- (void)doesNotRecognizeSelector:(SEL)aSelector __used
130130
{
131-
wasUsed = YES;
132131
[NSException raise:NSInvalidArgumentException format:@"%@: cannot stub/expect/verify method '%@' because no such method exists in the mocked class.", mockObject, NSStringFromSelector(aSelector)];
133132
}
134133

0 commit comments

Comments
 (0)