forked from Polidea/ios-class-guard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better property/method names deduction
- Loading branch information
Blazej Marcinkiewicz
committed
Jul 10, 2014
1 parent
1bded38
commit 6c5eb4f
Showing
16 changed files
with
623 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
xcuserdata | ||
*.xcarchive/ | ||
.idea | ||
Pods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
#import <Kiwi/Kiwi.h> | ||
|
||
#import "CDSymoblsGeneratorVisitor.h" | ||
#import "CDOCProperty.h" | ||
#import "NSString-CDExtensions.h" | ||
#import "CDOCMethod.h" | ||
|
||
SPEC_BEGIN(CDSymoblsGeneratorVisitorSpec) | ||
|
||
describe(@"CDSymoblsGeneratorVisitor", ^{ | ||
__block CDSymoblsGeneratorVisitor *visitor; | ||
|
||
beforeEach(^{ | ||
visitor = [[CDSymoblsGeneratorVisitor alloc] init]; | ||
}); | ||
|
||
describe(@"visiting property", ^{ | ||
|
||
NSString *propertyName = @"propertyName"; | ||
CDOCProperty *aProperty = [[CDOCProperty alloc] initWithName:propertyName attributes:@""]; | ||
|
||
context(@"when obfuscating plain property", ^{ | ||
it(@"should generate symbol for default getter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define %@", propertyName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for default setter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define set%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for iVar", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define _%@", propertyName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for 'is' property getter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define is%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
|
||
it(@"should generate symbol for 'setIs' setter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define setIs%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for 'setIs' iVar", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:aProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define _is%@ _is", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
}); | ||
|
||
context(@"when obfuscating 'is' property", ^{ | ||
CDOCProperty *isProperty = [[CDOCProperty alloc] initWithName:[@"is" stringByAppendingString:[propertyName capitalizeFirstCharacter]] attributes:@""]; | ||
|
||
it(@"should generate symbol for default getter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define %@", propertyName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for default setter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define set%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for iVar", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define _%@", propertyName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for 'is' property getter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define is%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
|
||
it(@"should generate symbol for plain setter for 'is' property", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define set%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for 'setIs' setter for 'is' property", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define setIs%@", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
it(@"should generate symbol for 'setIs' setter for 'is' property", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitProperty:isProperty]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define _is%@ _is", [propertyName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
}); | ||
}); | ||
|
||
describe(@"visiting method", ^{ | ||
NSString *methodName = @"methodName"; | ||
__block CDOCMethod *method; | ||
|
||
beforeEach(^{ | ||
method = [[CDOCMethod alloc] initWithName:methodName typeString:@""]; | ||
}); | ||
|
||
it(@"should generate symbol for method", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitInstanceMethod:method propertyState:nil]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define %@", methodName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
|
||
context(@"when method is a setter", ^{ | ||
beforeEach(^{ | ||
method = [[CDOCMethod alloc] initWithName:[@"set" stringByAppendingString:[methodName capitalizeFirstCharacter]] typeString:nil]; | ||
}); | ||
|
||
it(@"should generate symbol for getter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitInstanceMethod:method propertyState:nil]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define %@", methodName]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
}); | ||
|
||
context(@"when method is a getter", ^{ | ||
beforeEach(^{ | ||
method = [[CDOCMethod alloc] initWithName:methodName typeString:nil]; | ||
}); | ||
|
||
it(@"should generate symbol for setter", ^{ | ||
[visitor willBeginVisiting]; | ||
|
||
[visitor visitInstanceMethod:method propertyState:nil]; | ||
|
||
[visitor didEndVisiting]; | ||
|
||
NSInteger location = [visitor.resultString rangeOfString:[NSString stringWithFormat:@"#define set%@", [methodName capitalizeFirstCharacter]]].location; | ||
[[theValue(location) shouldNot] equal:theValue(NSNotFound)]; | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
SPEC_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target :UnitTests do | ||
pod 'Kiwi/XCTest' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
PODS: | ||
- Kiwi/ARC (2.2.4) | ||
- Kiwi/NonARC (2.2.4) | ||
- Kiwi/XCTest (2.2.4): | ||
- Kiwi/ARC | ||
- Kiwi/NonARC | ||
|
||
DEPENDENCIES: | ||
- Kiwi/XCTest | ||
|
||
SPEC CHECKSUMS: | ||
Kiwi: c73667f2b84cbf36f1a3830267c5a4ae8dcbd8ba | ||
|
||
COCOAPODS: 0.33.1 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.