Permalink
Browse files

Implemented debugDescription method for returning detailed object des…

…cription with full debug information, updated log messages to include more information about source and fixed appledoc target to make it compile.

Note that at this point debug information simply returns description.
  • Loading branch information...
1 parent 4247d9b commit 49bc255068caa7107b98bf8b76763c01ca1f71b1 @tomaz committed Sep 24, 2010
View
6 Common/NSObject+GBObject.h
@@ -16,4 +16,10 @@
*/
@property (readonly) NSFileManager *fileManager;
+/** Description that can be used for debugging output.
+
+ By default the value of `[NSObject description]` is returned, but some classes may override and provide more detailed information.
+ */
+@property (readonly) NSString *debugDescription;
+
@end
View
4 Common/NSObject+GBObject.m
@@ -14,4 +14,8 @@ - (NSFileManager *)fileManager {
return [NSFileManager defaultManager];
}
+- (NSString *)debugDescription {
+ return [self description];
+}
+
@end
View
19 Model/GBAdoptedProtocolsProvider.h
@@ -20,8 +20,27 @@
@private
NSMutableSet *_protocols;
NSMutableDictionary *_protocolsByName;
+ id _parent;
}
+///---------------------------------------------------------------------------------------
+/// @name Initialization & disposal
+///---------------------------------------------------------------------------------------
+
+/** Initializes ivars provider with the given parent object.
+
+ The given parent object is set to each `GBIvarData` registered through `registerIvar:`. This is the designated initializer.
+
+ @param parent The parent object to be used for all registered ivars.
+ @return Returns initialized object.
+ @exception NSException Thrown if the given parent is `nil`.
+ */
+- (id)initWithParentObject:(id)parent;
+
+///---------------------------------------------------------------------------------------
+/// @name Adopted protocols handling
+///---------------------------------------------------------------------------------------
+
/** Registers the given protocol to the providers data.
If provider doesn't yet have the given protocol instance registered, the object is added to `protocols` list. If the same object is already registered, nothing happens.
View
14 Model/GBAdoptedProtocolsProvider.m
@@ -13,20 +13,28 @@ @implementation GBAdoptedProtocolsProvider
#pragma mark Initialization & disposal
-- (id)init {
+- (id)initWithParentObject:(id)parent {
+ NSParameterAssert(parent != nil);
+ GBLogDebug(@"Initializing adopted protocols provider for %@...", parent);
self = [super init];
if (self) {
+ _parent = [parent retain];
_protocols = [[NSMutableSet alloc] init];
_protocolsByName = [[NSMutableDictionary alloc] init];
}
return self;
}
+- (id)init {
+ [NSException raise:@"Initializer 'init' is not valid, use 'initWithParentObject:' instead!"];
+ return nil;
+}
+
#pragma mark Helper methods
- (void)registerProtocol:(GBProtocolData *)protocol {
NSParameterAssert(protocol != nil);
- GBLogDebug(@"Registering protocol %@...", protocol);
+ GBLogDebug(@"%@: Registering protocol %@...", _parent, protocol);
if ([_protocols containsObject:protocol]) return;
GBProtocolData *existingProtocol = [_protocolsByName objectForKey:protocol.nameOfProtocol];
if (existingProtocol) {
@@ -41,7 +49,7 @@ - (void)registerProtocol:(GBProtocolData *)protocol {
- (void)mergeDataFromProtocolsProvider:(GBAdoptedProtocolsProvider *)source {
if (!source || source == self) return;
- GBLogDebug(@"Merging data from implementation...");
+ GBLogDebug(@"%@: Merging adopted protocols from %@...", _parent, source->_parent);
for (GBProtocolData *sourceProtocol in source.protocols) {
GBProtocolData *existingProtocol = [_protocolsByName objectForKey:sourceProtocol.nameOfProtocol];
if (existingProtocol) {
View
4 Model/GBCategoryData.m
@@ -24,7 +24,7 @@ - (id)initWithName:(NSString *)name className:(NSString *)className {
if (self) {
_categoryName = name ? [name copy] : nil;
_className = [className copy];
- _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] init];
+ _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
_methods = [[GBMethodsProvider alloc] initWithParentObject:self];
}
return self;
@@ -34,7 +34,7 @@ - (id)initWithName:(NSString *)name className:(NSString *)className {
- (void)mergeDataFromObject:(id)source {
if (!source || source == self) return;
- GBLogDebug(@"%@: Merging data from implementation...", self);
+ GBLogDebug(@"%@: Merging data from %@...", self, source);
NSParameterAssert([[source nameOfClass] isEqualToString:self.nameOfClass]);
NSParameterAssert([source nameOfCategory] == self.nameOfCategory || [[source nameOfCategory] isEqualToString:self.nameOfCategory]); // allow nil for extensions!
[super mergeDataFromObject:source];
View
6 Model/GBClassData.m
@@ -23,7 +23,7 @@ - (id)initWithName:(NSString *)name {
self = [super init];
if (self) {
_className = [name copy];
- _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] init];
+ _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
_ivars = [[GBIvarsProvider alloc] initWithParentObject:self];
_methods = [[GBMethodsProvider alloc] initWithParentObject:self];
}
@@ -34,7 +34,7 @@ - (id)initWithName:(NSString *)name {
- (void)mergeDataFromObject:(id)source {
if (!source || source == self) return;
- GBLogDebug(@"%@: Merging data from implementation...", self);
+ GBLogDebug(@"%@: Merging data from %@...", self, source);
NSParameterAssert([[source nameOfClass] isEqualToString:self.nameOfClass]);
[super mergeDataFromObject:source];
@@ -44,7 +44,7 @@ - (void)mergeDataFromObject:(id)source {
if (![self nameOfSuperclass]) {
self.nameOfSuperclass = sourceClass.nameOfSuperclass;
} else if (sourceClass.nameOfSuperclass && ![self.nameOfSuperclass isEqualToString:sourceClass.nameOfSuperclass]) {
- GBLogWarn(@"%@: Merged class's superclass %@ is different from ours %@!", self, sourceClass.nameOfSuperclass, self.nameOfSuperclass);
+ GBLogWarn(@"%@: Merged class's %@ superclass is different from ours!", self, sourceClass);
}
// Forward merging request to components.
View
19 Model/GBComment.m
@@ -8,6 +8,7 @@
#import "GBCommentParagraph.h"
#import "GBCommentArgument.h"
+#import "GBParagraphLinkItem.h"
#import "GBComment.h"
@interface GBComment ()
@@ -38,7 +39,7 @@ + (id)commentWithStringValue:(NSString *)value sourceInfo:(GBSourceInfo *)info {
- (void)registerParagraph:(GBCommentParagraph *)paragraph {
NSParameterAssert(paragraph != nil);
- GBLogDebug(@"Registering paragraph %@...", paragraph);
+ GBLogDebug(@"%@: Registering paragraph %@...", self, paragraph);
if (!_paragraphs) {
_paragraphs = [[NSMutableArray alloc] init];
self.firstParagraph = paragraph;
@@ -49,41 +50,41 @@ - (void)registerParagraph:(GBCommentParagraph *)paragraph {
- (void)registerParameter:(GBCommentArgument *)parameter {
NSParameterAssert(parameter != nil);
NSParameterAssert([parameter.argumentName length] > 0);
- GBLogDebug(@"Registering parameter %@...", parameter);
+ GBLogDebug(@"%@: Registering parameter %@...", self, parameter);
if (!_parameters) _parameters = [[NSMutableArray alloc] init];
if ([self replaceArgumentWithSameNameInList:_parameters withArgument:parameter]) {
- GBLogWarn(@"Parameter with name %@ is already registered, replacing existing!", parameter.argumentName);
+ GBLogWarn(@"%@: Parameter with name %@ is already registered, replacing existing!", self, parameter.argumentName);
return;
}
[_parameters addObject:parameter];
}
- (void)registerResult:(GBCommentParagraph *)value {
NSParameterAssert(value != nil);
- GBLogDebug(@"Registering result %@...", value);
- if (self.result) GBLogWarn(@"Result is already registered, replacing existing!");
+ GBLogDebug(@"%@: Registering result %@...", self, value);
+ if (self.result) GBLogWarn(@"%@: Result is already registered, replacing existing!", self);
self.result = value;
}
- (void)registerException:(GBCommentArgument *)exception {
NSParameterAssert(exception != nil);
- GBLogDebug(@"Registering exception %@...", exception);
+ GBLogDebug(@"%@: Registering exception %@...", self, exception);
if (!_exceptions) _exceptions = [[NSMutableArray alloc] init];
if ([self replaceArgumentWithSameNameInList:_exceptions withArgument:exception]) {
- GBLogWarn(@"Exception with name %@ is already registered, replacing existing!", exception.argumentName);
+ GBLogWarn(@"%@: Exception with name %@ is already registered, replacing existing!", self, exception.argumentName);
return;
}
[_exceptions addObject:exception];
}
- (void)registerCrossReference:(GBParagraphLinkItem *)ref {
NSParameterAssert(ref != nil);
- GBLogDebug(@"Registering cross referece %@...", ref);
+ GBLogDebug(@"%@: Registering cross referece %@...", self, ref);
if (!_crossrefs) _crossrefs = [[NSMutableArray alloc] init];
for (NSUInteger i=0; i<[_crossrefs count]; i++) {
GBParagraphLinkItem *existing = [_crossrefs objectAtIndex:i];
if ([existing.stringValue isEqualToString:ref.stringValue]) {
- GBLogWarn(@"Cross reference %@ is already registered, ignoring!", ref.stringValue);
+ GBLogWarn(@"%@: Cross reference %@ is already registered, ignoring!", self, ref.stringValue);
return;
}
}
View
2 Model/GBCommentParagraph.m
@@ -29,7 +29,7 @@ - (id)init {
- (void)registerItem:(GBParagraphItem *)item {
NSParameterAssert(item != nil);
- GBLogDebug(@"Registering paragraph item of type %@...", [item className]);
+ GBLogDebug(@"%@: Registering paragraph item of type %@...", self, [item className]);
[_items addObject:item];
}
View
2 Model/GBIvarData.m
@@ -33,7 +33,7 @@ - (id)initWithDataFromComponents:(NSArray *)components {
- (void)mergeDataFromObject:(id)source {
if (!source || source == self) return;
- GBLogDebug(@"%@: Merging data from implementation...", self);
+ GBLogDebug(@"%@: Merging data from %@...", self, source);
NSParameterAssert([[source nameOfIvar] isEqualToString:self.nameOfIvar]);
NSParameterAssert([[source ivarTypes] isEqualToArray:self.ivarTypes]);
[super mergeDataFromObject:source];
View
6 Model/GBIvarsProvider.m
@@ -15,7 +15,7 @@ @implementation GBIvarsProvider
- (id)initWithParentObject:(id)parent {
NSParameterAssert(parent != nil);
- GBLogDebug(@"Initializing provider for %@...", parent);
+ GBLogDebug(@"Initializing ivars provider for %@...", parent);
self = [super init];
if (self) {
_parent = [parent retain];
@@ -29,7 +29,7 @@ - (id)initWithParentObject:(id)parent {
- (void)registerIvar:(GBIvarData *)ivar {
NSParameterAssert(ivar != nil);
- GBLogDebug(@"Registering ivar %@...", ivar);
+ GBLogDebug(@"%@: Registering ivar %@...", _parent, ivar);
if ([_ivars containsObject:ivar]) return;
GBIvarData *existingIvar = [_ivarsByName objectForKey:ivar.nameOfIvar];
if (existingIvar) {
@@ -43,7 +43,7 @@ - (void)registerIvar:(GBIvarData *)ivar {
- (void)mergeDataFromIvarsProvider:(GBIvarsProvider *)source {
if (!source || source == self) return;
- GBLogDebug(@"Merging data from implementation...");
+ GBLogDebug(@"%@: Merging ivars from %@...", _parent, source->_parent);
for (GBIvarData *sourceIvar in source.ivars) {
GBIvarData *existingIvar = [_ivarsByName objectForKey:sourceIvar.nameOfIvar];
if (existingIvar) {
View
2 Model/GBMethodData.m
@@ -62,7 +62,7 @@ - (NSString *)selectorFromAssignedData {
- (void)mergeDataFromObject:(id)source {
if (!source || source == self) return;
- GBLogDebug(@"%@: Merging data from implementation...", self);
+ GBLogDebug(@"%@: Merging data from %@...", self, source);
NSParameterAssert([source methodType] == self.methodType);
NSParameterAssert([source methodAttributes] == self.methodAttributes || [[source methodAttributes] isEqualToArray:self.methodAttributes]); // allow nil!
NSParameterAssert([[source methodSelector] isEqualToString:self.methodSelector]);
View
9 Model/GBMethodsProvider.m
@@ -7,6 +7,7 @@
//
#import "GBMethodData.h"
+#import "GBMethodSectionData.h"
#import "GBMethodsProvider.h"
@implementation GBMethodsProvider
@@ -15,7 +16,7 @@ @implementation GBMethodsProvider
- (id)initWithParentObject:(id)parent {
NSParameterAssert(parent != nil);
- GBLogDebug(@"Initializing provider for %@...", parent);
+ GBLogDebug(@"Initializing methods provider for %@...", parent);
self = [super init];
if (self) {
_parent = [parent retain];
@@ -29,7 +30,7 @@ - (id)initWithParentObject:(id)parent {
#pragma mark Registration methods
- (GBMethodSectionData *)registerSectionWithName:(NSString *)name {
- GBLogDebug(@"Registering section %@...", name);
+ GBLogDebug(@"%@: Registering section %@...", _parent, name);
GBMethodSectionData *section = [[[GBMethodSectionData alloc] init] autorelease];
section.sectionName = name;
[_sections addObject:section];
@@ -46,7 +47,7 @@ - (GBMethodSectionData *)registerSectionIfNameIsValid:(NSString *)string {
- (void)registerMethod:(GBMethodData *)method {
// Note that we allow adding several methods with the same selector as long as the type is different (i.e. class and instance methods). In such case, methodBySelector will preffer instance method or property to class method! Note that this could be implemented more inteligently by prefixing selectors with some char or similar and then handling that within methodBySelector: and prefer instance/property in there. However at the time being current code seems sufficient and simpler, so let's stick with it for a while...
NSParameterAssert(method != nil);
- GBLogDebug(@"Registering method %@...", method);
+ GBLogDebug(@"%@: Registering method %@...", _parent, method);
if ([_methods containsObject:method]) return;
GBMethodData *existingMethod = [_methodsBySelectors objectForKey:method.methodSelector];
if (existingMethod && existingMethod.methodType == method.methodType) {
@@ -68,7 +69,7 @@ - (void)registerMethod:(GBMethodData *)method {
- (void)mergeDataFromMethodsProvider:(GBMethodsProvider *)source {
// If a method with the same selector is found while merging from source, we should check if the type also matches. If so, we can merge the data from the source's method. However if the type doesn't match, we should ignore the method alltogether (ussually this is due to custom property implementation). We should probably deal with this scenario more inteligently, but it seems it works...
if (!source || source == self) return;
- GBLogDebug(@"Merging data from implementation...");
+ GBLogDebug(@"%@: Merging methods from %@...", _parent, source->_parent);
for (GBMethodData *sourceMethod in source.methods) {
GBMethodData *existingMethod = [_methodsBySelectors objectForKey:sourceMethod.methodSelector];
if (existingMethod) {
View
3 Model/GBModelBase.m
@@ -7,6 +7,7 @@
//
#import "GBComment.h"
+#import "GBSourceInfo.h"
#import "GBModelBase.h"
@implementation GBModelBase
@@ -46,7 +47,7 @@ - (void)mergeDataFromObject:(id)source {
// Merge comment.
GBComment *comment = [(GBModelBase *)source comment];
if (self.comment && comment) {
- GBLogWarn(@"%@: Comment string found in definition and declaration!", self);
+ GBLogWarn(@"%@: Comment found in %@ and %@!", self, self.comment.sourceInfo, comment.sourceInfo);
return;
}
if (!self.comment && comment) self.comment = comment;
View
4 Model/GBParagraphDecoratorItem.m
@@ -24,12 +24,12 @@ - (id)init {
- (void)registerItem:(GBParagraphItem *)item {
NSParameterAssert(item != nil);
- GBLogDebug(@"Registering item %@...", item);
+ GBLogDebug(@"%@: Registering item %@...", self, item);
[_decoratedItems addObject:item];
}
- (void)replaceItemsByRegisteringItemsFromArray:(NSArray *)items {
- GBLogDebug(@"Registering %ld items...", [items count]);
+ GBLogDebug(@"%@: Registering %ld items...", self, [items count]);
if (!items || [items count] == 0) return;
[_decoratedItems removeAllObjects];
[items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
View
4 Model/GBProtocolData.m
@@ -23,7 +23,7 @@ - (id)initWithName:(NSString *)name {
self = [super init];
if (self) {
_protocolName = [name copy];
- _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] init];
+ _adoptedProtocols = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
_methods = [[GBMethodsProvider alloc] initWithParentObject:self];
}
return self;
@@ -33,7 +33,7 @@ - (id)initWithName:(NSString *)name {
- (void)mergeDataFromObject:(id)source {
if (!source || source == self) return;
- GBLogDebug(@"%@: Merging data from implementation...", self);
+ GBLogDebug(@"%@: Merging data from %@...", self, source);
NSParameterAssert([[source nameOfProtocol] isEqualToString:self.nameOfProtocol]);
[super mergeDataFromObject:source];
GBProtocolData *sourceProtocol = (GBProtocolData *)source;
View
2 Model/GBStore.m
@@ -55,7 +55,7 @@ - (NSArray *)protocolsSortedByName {
- (void)registerClass:(GBClassData *)class {
NSParameterAssert(class != nil);
- GBLogDebug(@"Registering class %@...", class);
+ GBLogDebug(@"%Registering class %@...", class);
if ([_classes containsObject:class]) return;
GBClassData *existingClass = [_classesByName objectForKey:class.nameOfClass];
if (existingClass) {
View
2 Parsing/GBTokenizer.m
@@ -8,6 +8,8 @@
#import "RegexKitLite.h"
#import "PKToken+GBToken.h"
+#import "GBSourceInfo.h"
+#import "GBComment.h"
#import "GBTokenizer.h"
@interface GBTokenizer ()
View
18 Processing/GBCommentsProcessor.m
@@ -84,7 +84,7 @@ - (void)processComment:(GBComment *)comment withContext:(id<GBObjectDataProvidin
NSParameterAssert(comment != nil);
NSParameterAssert(store != nil);
NSParameterAssert([store conformsToProtocol:@protocol(GBStoreProviding)]);
- GBLogDebug(@"Processing comment with store %@...", store);
+ GBLogDebug(@"Processing comment %@ with store %@...", comment, store);
self.currentComment = comment;
self.currentContext = context;
self.store = store;
@@ -180,7 +180,7 @@ - (GBCommentParagraph *)registerArgumentsFromString:(NSString *)string {
result = nil;
} else {
NSString *directive = [string stringByMatching:componizer.argumentsMatchingRegex];
- GBLogWarn(@"Directive %@ has invalid syntax in %@!", directive, string);
+ GBLogWarn(@"%@: Directive %@ has invalid syntax in %@!", self.currentComment, directive, string);
}
if (length == [string length]) break;
string = [string substringFromIndex:length];
@@ -300,7 +300,7 @@ - (NSArray *)flattenedListItemsFromString:(NSString *)string {
NSString *previousDesc = [previousData objectForKey:@"description"]; \
[previousData setObject:[NSString stringWithFormat:@"%@%@", previousDesc, text] forKey:@"description"]; \
} else { \
- GBLogWarn(@"Found text '%@' at the start of the list:\n%@", string); \
+ GBLogWarn(@"%@: Found text '%@' at the start of the list:\n%@", self.currentComment, string); \
} \
}
NSMutableArray *result = [NSMutableArray array];
@@ -372,12 +372,12 @@ - (void)registerExampleFromString:(NSString *)string toParagraph:(GBCommentParag
// Warn if empty example was found or not all text was processed (note that we calculate remaining text by checking source and processed string length and taking into account all leading tabs that were removed!).
if ([example length] == 0) {
- GBLogWarn(@"Empty example section found!");
+ GBLogWarn(@"%@: Empty example section found!", self.currentComment);
return;
}
if ([example length] < [string length] - [lines count]) {
NSString *remaining = [string substringFromIndex:[example length] + [lines count]];
- GBLogWarn(@"Not all text was processed - '%@' was left, make sure an empty line without tabs is inserted before next paragraph!", [remaining stringByReplacingOccurrencesOfRegex:self.spaceAndNewLineTrimRegex withString:@""]);
+ GBLogWarn(@"%@: Not all text was processed - '%@' was left, make sure an empty line without tabs is inserted before next paragraph!", self.currentComment, [remaining stringByReplacingOccurrencesOfRegex:self.spaceAndNewLineTrimRegex withString:@""]);
}
// Prepare paragraph item and process the text. Note that we don't use standard text processing here as it would interfere with example formatting.
@@ -394,7 +394,7 @@ - (void)registerSpecialFromString:(NSString *)string type:(GBSpecialItemType)typ
// Get the description from the string. If empty, warn and exit.
NSString *description = [string stringByMatching:regex capture:1];
if ([description length] == 0) {
- GBLogWarn(@"Empty special section of type %ld found!", type);
+ GBLogWarn(@"%@: Empty special section of type %ld found!", self.currentComment, type);
return;
}
@@ -548,7 +548,7 @@ - (NSArray *)paragraphTextItemsFromString:(NSString *)string {
inner.decorationType = GBDecorationTypeItalics;
[inner registerItem:[GBParagraphTextItem paragraphItemWithStringValue:text]];
} else {
- GBLogError(@"Unknown text decorator type %@ detected!", type);
+ GBLogError(@"%@: Unknown text decorator type %@ detected!", self.currentComment, type);
decorator = nil;
}
if (decorator) [result addObject:decorator];
@@ -605,7 +605,7 @@ - (GBParagraphLinkItem *)remoteMemberLinkItemFromString:(NSString *)string match
}
}
if (!objectRefence) {
- GBLogWarn(@"Invalid object reference: %@ object not found!", objectName);
+ GBLogWarn(@"%@: Invalid object reference: %@ object not found!", self.currentComment, objectName);
return nil;
}
@@ -620,7 +620,7 @@ - (GBParagraphLinkItem *)remoteMemberLinkItemFromString:(NSString *)string match
link.isLocal = NO;
return link;
} else {
- GBLogWarn(@"Invalid object reference for %@: member %@ not found!", objectRefence, memberName);
+ GBLogWarn(@"%@: Invalid object reference for %@: member %@ not found!", self.currentComment, objectRefence, memberName);
return nil;
}
View
2 Processing/GBProcessor.m
@@ -120,7 +120,7 @@ - (void)processMethodsFromProvider:(GBMethodsProvider *)provider {
- (void)processComment:(GBComment *)comment {
if (!comment) return;
- GBLogDebug(@"Processing comment...");
+ GBLogDebug(@"Processing comment %@...", comment);
[self.commentsProcessor processComment:comment withContext:self.currentContext store:self.store];
}
View
16 Testing/GBAdoptedProtocolsProviderTesting.m
@@ -18,7 +18,7 @@ @implementation GBAdoptedProtocolsProviderTesting
- (void)testRegisterProtocol_shouldAddProtocolToList {
// setup
- GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
GBProtocolData *protocol = [[GBProtocolData alloc] initWithName:@"MyProtocol"];
// execute
[provider registerProtocol:protocol];
@@ -30,7 +30,7 @@ - (void)testRegisterProtocol_shouldAddProtocolToList {
- (void)testRegisterProtocol_shouldIgnoreSameInstance {
// setup
- GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
GBProtocolData *protocol = [[GBProtocolData alloc] initWithName:@"MyProtocol"];
// execute
[provider registerProtocol:protocol];
@@ -41,7 +41,7 @@ - (void)testRegisterProtocol_shouldIgnoreSameInstance {
- (void)testRegisterProtocol_shouldMergeDifferentInstanceWithSameName {
// setup
- GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
GBProtocolData *source = [[GBProtocolData alloc] initWithName:@"MyProtocol"];
OCMockObject *original = [OCMockObject niceMockForClass:[GBProtocolData class]];
[[[original stub] andReturn:@"MyProtocol"] nameOfProtocol];
@@ -57,10 +57,10 @@ - (void)testRegisterProtocol_shouldMergeDifferentInstanceWithSameName {
- (void)testMergeDataFromProtocolProvider_shouldMergeAllDifferentProtocols {
// setup
- GBAdoptedProtocolsProvider *original = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *original = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
[original registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[original registerProtocol:[GBProtocolData protocolDataWithName:@"P2"]];
- GBAdoptedProtocolsProvider *source = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *source = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
[source registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[source registerProtocol:[GBProtocolData protocolDataWithName:@"P3"]];
// execute
@@ -75,10 +75,10 @@ - (void)testMergeDataFromProtocolProvider_shouldMergeAllDifferentProtocols {
- (void)testMergeDataFromProtocolProvider_shouldPreserveSourceData {
// setup
- GBAdoptedProtocolsProvider *original = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *original = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
[original registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[original registerProtocol:[GBProtocolData protocolDataWithName:@"P2"]];
- GBAdoptedProtocolsProvider *source = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *source = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
[source registerProtocol:[GBProtocolData protocolDataWithName:@"P1"]];
[source registerProtocol:[GBProtocolData protocolDataWithName:@"P3"]];
// execute
@@ -94,7 +94,7 @@ - (void)testMergeDataFromProtocolProvider_shouldPreserveSourceData {
- (void)testReplaceProtocolWithProtocol_shouldReplaceObjects {
// setup
- GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] init];
+ GBAdoptedProtocolsProvider *provider = [[GBAdoptedProtocolsProvider alloc] initWithParentObject:self];
GBProtocolData *protocol1 = [GBProtocolData protocolDataWithName:@"P1"];
GBProtocolData *protocol2 = [GBProtocolData protocolDataWithName:@"P2"];
GBProtocolData *protocol3 = [GBProtocolData protocolDataWithName:@"P3"];

0 comments on commit 49bc255

Please sign in to comment.