Permalink
Browse files

Clean up all of the build warnings coming out of the UISpec code

  • Loading branch information...
1 parent ff01e4b commit b8c03375f4ba495d89c02e7e435ef979208b3df8 @blakewatters blakewatters committed Aug 3, 2011
View
4 Specs/Runner/UISpecRunner/NSNumberCreator.h
@@ -17,6 +17,6 @@ __typeof__(aValue) __aValue = (aValue); \
}) \
@interface NSNumberCreator : NSObject
-+ numberWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
-- initWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
++ (NSValue*)numberWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
+- (NSValue*)initWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
@end
View
4 Specs/Runner/UISpecRunner/NSNumberCreator.m
@@ -1,13 +1,13 @@
#import "NSNumberCreator.h"
@implementation NSNumberCreator
-+ numberWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
++ (NSValue*)numberWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
{
return [[[self alloc] initWithValue:aValue objCType:aTypeDescription] autorelease];
}
/// For the constants see: <http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_14_section_9.html>
-- initWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
+- (NSValue*)initWithValue:(const void *)aValue objCType:(const char *)aTypeDescription;
{
if ('^' == *aTypeDescription
&& nil == *(id *)aValue) return nil; // nil should stay nil, even if it's technically a (void *)
View
2 Specs/Runner/UISpecRunner/UIExpectation.h
@@ -36,7 +36,7 @@ __typeof__(aValue) __aValue = (aValue); \
}
@property(nonatomic, readonly) UIExpectation *not, *have, *be, *should, *shouldNot;
-@property(nonatomic, readonly) BOOL exist;
+//@property(nonatomic, readonly) BOOL exist;
+(id)withValue:(const void *)aValue objCType:(const char *)aTypeDescription file:(const char *)aFile line:(int)aLine isFailureTest:(BOOL)failureTest;
+(SEL)makeIsSelector:(SEL)aSelector;
View
13 Specs/Runner/UISpecRunner/UIExpectation.m
@@ -1,4 +1,4 @@
-
+#import <objc/message.h>
#import "UIExpectation.h"
// #import "UIRedoer.h"
// #import "UIQueryExpectation.h"
@@ -79,7 +79,10 @@ -(void)be:(SEL)sel {
if (![value respondsToSelector:sel] && [value respondsToSelector:[UIExpectation makeIsSelector:sel]]) {
sel = [UIExpectation makeIsSelector:sel];
}
- BOOL result = [value performSelector:sel];
+ BOOL (*BoolReturnPerformSelector)(id, SEL) = (BOOL (*)(id, SEL)) objc_msgSend;
+ BOOL result = BoolReturnPerformSelector(self, sel);
+ //BOOL result = [value performSelector:sel];
+
if ((result == YES && isNot) || (result == NO && !isNot)) {
if (!isFailureTest) {
[NSException raise:nil format:@"%@ did not pass condition: [%@ be %@]\n%s:%d", [self valueAsString], (isNot ? @"should not" : @"should"), origSelector, file, line];
@@ -95,7 +98,7 @@ -(void)have:(NSInvocation *)invocation {
BOOL foundErrors = NO;
NSMutableArray *errors = [NSMutableArray array];
int i = 2;
- const void * expected = nil;
+ id<NSObject> expected = nil;
for (NSString *key in selectors) {
if (![key isEqualToString:@""]) {
SEL selector = NSSelectorFromString(key);
@@ -108,7 +111,7 @@ -(void)have:(NSInvocation *)invocation {
NSString *returnType = [NSString stringWithFormat:@"%s", [[value methodSignatureForSelector:selector] methodReturnType]];
if ([returnType isEqualToString:@"@"]) {
if ([expected isKindOfClass:[NSString class]]) {
- if ([[value performSelector:selector] rangeOfString:expected].length == 0) {
+ if ([[value performSelector:selector] rangeOfString:(NSString*)expected].length == 0) {
[errors addObject:[NSString stringWithFormat:@"%@ : '%@' doesn't contain '%@'", key, [value performSelector:selector], expected]];
foundErrors = YES;
continue;
@@ -139,7 +142,6 @@ -(NSString *)valueAsString {
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
- NSMutableString *selector = NSStringFromSelector(aSelector);
if (isBe) {
if (![value respondsToSelector:aSelector] && [value respondsToSelector:[UIExpectation makeIsSelector:aSelector]]) {
aSelector = [UIExpectation makeIsSelector:aSelector];
@@ -168,7 +170,6 @@ - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
}
- (void)forwardInvocation:(NSInvocation *)anInvocation {
- NSMutableString *selector = [NSMutableString stringWithString:NSStringFromSelector([anInvocation selector])];
if (isBe) {
[self be:[anInvocation selector]];
} else if (isHave) {
View
2 Specs/Runner/UISpecRunner/UIMatcher.h
@@ -6,7 +6,7 @@
@end
-@interface UIMatcher : NSObject <UIMatcher>{
+@interface UIMatcher : NSObject { // <UIMatcher>{
id expectedValue;
const char * expectedTypeDescription;
SEL matchSelector;
View
7 Specs/Runner/UISpecRunner/UIMatcher.m
@@ -1,4 +1,5 @@
+#import <objc/message.h>
#import "UIMatcher.h"
#import "NSNumberCreator.h"
@@ -20,7 +21,9 @@ -(id)initWithValue:(const void *)aValue objCType:(const char *)aTypeDescription
}
-(BOOL)matches:(id)value {
- return [self performSelector:matchSelector withObject:value];
+// return [self performSelector:matchSelector withObject:value];
+ BOOL (*BoolReturnPerformSelector)(id, SEL, id) = (BOOL (*)(id, SEL, id)) objc_msgSend;
+ return BoolReturnPerformSelector(self, matchSelector, value);
}
-(BOOL)be:(id)value {
@@ -35,7 +38,7 @@ +(NSString *)valueAsString:(const void *)value objCType:(const char *)typeDescri
if ('@' == *typeDescription) {
return [NSString stringWithFormat:@"%@", *(id *)value];
}
- return [[NSNumber numberWithValue:value objCType:typeDescription] stringValue];
+ return [(NSNumber*)[NSNumberCreator numberWithValue:value objCType:typeDescription] stringValue];
}
- (void)dealloc {
View
12 Specs/Runner/UISpecRunner/UISpec.h
@@ -20,7 +20,7 @@
+(void)runSpec:(NSTimer *)timer;
+(void)runSpecExample:(NSTimer *)timer;
+(void)runSpecClasses:(NSArray *)specClasses;
-+(void)runExamples:(NSArray *)examples onSpec:(Class *)class;
++(void)runExamples:(NSArray *)examples onSpec:(Class)class;
+(void)setLog:(UILog *)log;
+(NSDictionary *)specsAndExamples;
@@ -45,6 +45,12 @@
@end
-@protocol UISpec
-@end
+@protocol UISpec <NSObject>
+
+@optional
+- (void)beforeAll;
+- (void)before;
+- (void)after;
+- (void)afterAll;
+@end
View
21 Specs/Runner/UISpecRunner/UISpec.m
@@ -2,12 +2,17 @@
#import "objc/runtime.h"
#import "UIConsoleLog.h"
+@interface UISpec ()
++(NSArray *)examplesForSpecClass:(Class)specClass;
++(NSArray*)specClasses;
+@end
+
@implementation UISpec
static UILog *logger = nil;
+(void)initialize {
- logger = [[UIConsoleLog alloc] init];
+ logger = (UILog *) [[UIConsoleLog alloc] init];
}
+(void)setLog:(UILog *)log{
@@ -33,12 +38,12 @@ +(void)runSpecs {
}
+(void)runSpec:(NSTimer *)timer {
- Class *class = NSClassFromString(timer.userInfo);
+ Class class = NSClassFromString(timer.userInfo);
[self runSpecClasses:[NSArray arrayWithObject:class]];
}
+(void)runSpecExample:(NSTimer *)timer {
- Class *class = NSClassFromString([timer.userInfo objectAtIndex:0]);
+ Class class = NSClassFromString([timer.userInfo objectAtIndex:0]);
NSString *exampleName = [timer.userInfo objectAtIndex:1];
[logger onStart];
[self runExamples:[NSArray arrayWithObject:exampleName] onSpec:class];
@@ -58,8 +63,8 @@ +(void)runSpecClasses:(NSArray *)specClasses {
[logger onFinish:examplesCount];
}
-+(void)runExamples:(NSArray *)examples onSpec:(Class *)class {
- UISpec *spec = [[[class alloc] init] autorelease];
++(void)runExamples:(NSArray *)examples onSpec:(Class)class {
+ id<UISpec> spec = [[[class alloc] init] autorelease];
[logger onSpec:spec];
if ([spec respondsToSelector:@selector(beforeAll)]) {
@try {
@@ -110,13 +115,13 @@ +(NSDictionary *)specsAndExamples {
for (Class specClass in specClasses) {
NSArray *examples = [self examplesForSpecClass:specClass];
if ([examples count]) {
- [specsAndExamples addObject:examples forKey:NSStringFromClass(specClass)];
+ [specsAndExamples setObject:examples forKey:NSStringFromClass(specClass)];
}
}
return specsAndExamples;
}
-+(NSArray *)examplesForSpecClass:(Class *)specClass {
++(NSArray *)examplesForSpecClass:(Class)specClass {
NSMutableArray *array = [NSMutableArray array];
unsigned int methodCount;
Method *methods = class_copyMethodList(specClass, &methodCount);
@@ -150,7 +155,7 @@ +(NSArray*)specClasses {
(void) objc_getClassList (classes, numClasses);
int i;
for (i = 0; i < numClasses; i++) {
- Class *c = classes[i];
+ Class c = classes[i];
if ([self isASpec:c]) {
[array addObject:c];
}

0 comments on commit b8c0337

Please sign in to comment.