Authored by Craig Siemens

Added tests and examples for layout guides

Showing 100 changed files with 152 additions and 133 deletions

Too many changes to show.

To preserve performance only 100 of 100+ files are displayed.

... ... @@ -38,6 +38,7 @@
114413081924B6EE008E702E /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
27A27D441A6CF0C400D34F52 /* MASExampleAspectFitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleAspectFitView.h; sourceTree = "<group>"; };
27A27D451A6CF0C400D34F52 /* MASExampleAspectFitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleAspectFitView.m; sourceTree = "<group>"; };
321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.release.xcconfig"; path = "../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples.release.xcconfig"; sourceTree = "<group>"; };
3C02224819D0C4EC00507321 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
3DB1CAD3184538E200E91FC5 /* MASExampleArrayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleArrayView.h; sourceTree = "<group>"; };
3DB1CAD4184538E200E91FC5 /* MASExampleArrayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleArrayView.m; sourceTree = "<group>"; };
... ... @@ -45,7 +46,7 @@
44C0E6AE1A9B9C55003C70CF /* MASExampleMarginView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleMarginView.m; sourceTree = "<group>"; };
4BEB55B41957394E008C862B /* MASExampleRemakeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleRemakeView.h; sourceTree = "<group>"; };
4BEB55B51957394E008C862B /* MASExampleRemakeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleRemakeView.m; sourceTree = "<group>"; };
B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.xcconfig"; path = "../Pods/Pods-Masonry iOS Examples.xcconfig"; sourceTree = "<group>"; };
50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Masonry iOS Examples.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples.debug.xcconfig"; sourceTree = "<group>"; };
BDC1B8303EED42A2B01B94B1 /* libPods-Masonry iOS Examples.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Masonry iOS Examples.a"; sourceTree = BUILT_PRODUCTS_DIR; };
DD175E68182639FB0099129A /* MASExampleUpdateView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASExampleUpdateView.h; sourceTree = "<group>"; };
DD175E69182639FB0099129A /* MASExampleUpdateView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASExampleUpdateView.m; sourceTree = "<group>"; };
... ... @@ -105,7 +106,7 @@
DD52F230179CAD57005CD195 /* Masonry iOS Examples */,
DD52F229179CAD57005CD195 /* Frameworks */,
DD52F228179CAD57005CD195 /* Products */,
B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */,
DF14AF6879B23556F891E1F7 /* Pods */,
);
sourceTree = "<group>";
};
... ... @@ -198,6 +199,15 @@
name = Controllers;
sourceTree = "<group>";
};
DF14AF6879B23556F891E1F7 /* Pods */ = {
isa = PBXGroup;
children = (
50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */,
321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
... ... @@ -273,7 +283,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/../Pods/Pods-Masonry iOS Examples-resources.sh\"\n";
shellScript = "\"${SRCROOT}/../Pods/Target Support Files/Pods-Masonry iOS Examples/Pods-Masonry iOS Examples-resources.sh\"\n";
showEnvVarsInLog = 0;
};
621F6A1FCAEF44F880874959 /* Check Pods Manifest.lock */ = {
... ... @@ -393,7 +403,7 @@
};
DD52F245179CAD57005CD195 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */;
baseConfigurationReference = 50B25D0621957AEB87C3FCC2 /* Pods-Masonry iOS Examples.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
... ... @@ -406,7 +416,7 @@
};
DD52F246179CAD57005CD195 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B086DD7D31DD4B49ADC08504 /* Pods-Masonry iOS Examples.xcconfig */;
baseConfigurationReference = 321AA59CF7B045B6D503D2E5 /* Pods-Masonry iOS Examples.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
... ...
... ... @@ -40,20 +40,15 @@
bottomView.layer.borderWidth = 2;
[self.view addSubview:bottomView];
// TODO find way that avoids casting
// layoutGuides are actually UIView subclasses so can be used in Masonry
// However casting to UIView is not ideal if Apple decides to change underlying implementation of layoutGuides this will break
[topView makeConstraints:^(MASConstraintMaker *make) {
UIView *topLayoutGuide = (id)self.topLayoutGuide;
make.top.equalTo(topLayoutGuide.bottom);
make.top.equalTo(self.mas_topLayoutGuide);
make.left.equalTo(self.view);
make.right.equalTo(self.view);
make.height.equalTo(@40);
}];
[bottomView makeConstraints:^(MASConstraintMaker *make) {
UIView *bottomLayoutGuide = (id)self.bottomLayoutGuide;
make.bottom.equalTo(bottomLayoutGuide.top);
make.bottom.equalTo(self.mas_bottomLayoutGuide);
make.left.equalTo(self.view);
make.right.equalTo(self.view);
make.height.equalTo(@40);
... ...
... ... @@ -53,8 +53,10 @@
3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DC1AD5A0470053CC65 /* MASCompositeConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; };
3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05ED1AD5A0470053CC65 /* NSLayoutConstraint+MASDebugAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */ = {isa = PBXBuildFile; fileRef = 3AED05DE1AD5A0470053CC65 /* MASConstraint.h */; settings = {ATTRIBUTES = (Public, ); }; };
4473548D1B39F772004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; };
4473548D1B39F772004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
4473548E1B39F772004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; };
447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; };
447354931B3A18B9004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
... ... @@ -204,6 +206,7 @@
3AED061E1AD5A1400053CC65 /* MASUtilities.h in Headers */,
3AED061F1AD5A1400053CC65 /* NSArray+MASAdditions.h in Headers */,
3AED06201AD5A1400053CC65 /* MASCompositeConstraint.h in Headers */,
447354931B3A18B9004DACCB /* ViewController+MASAdditions.h in Headers */,
3AED06221AD5A1400053CC65 /* MASConstraint.h in Headers */,
3AED061D1AD5A1400053CC65 /* MASConstraint+Private.h in Headers */,
3AED06211AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.h in Headers */,
... ... @@ -326,6 +329,7 @@
3AED060D1AD5A1400053CC65 /* MASConstraint.m in Sources */,
3AED060E1AD5A1400053CC65 /* MASViewConstraint.m in Sources */,
3AED060F1AD5A1400053CC65 /* MASCompositeConstraint.m in Sources */,
447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */,
3AED06101AD5A1400053CC65 /* MASConstraintMaker.m in Sources */,
3AED06111AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */,
3AED06121AD5A1400053CC65 /* View+MASAdditions.m in Sources */,
... ...
PODS:
- Expecta (0.3.0)
- Masonry (0.5.0)
- Expecta (1.0.0)
- Masonry (0.6.1)
DEPENDENCIES:
- Expecta
... ... @@ -8,10 +8,10 @@ DEPENDENCIES:
EXTERNAL SOURCES:
Masonry:
:path: ./
:path: "./"
SPEC CHECKSUMS:
Expecta: 322f1dc42610106a5ba9871b4924cf1635d80833
Masonry: bef482b29f00b33a2da916e1011af85f5d371d66
Expecta: 32604574add2c46a36f8d2f716b6c5736eb75024
Masonry: 4972309f2f134de9dd312f4dc4a21359b50e6caa
COCOAPODS: 0.32.1
COCOAPODS: 0.37.2
... ...
../../Expecta/src/EXPBackwardCompatibility.h
\ No newline at end of file
../../Expecta/src/EXPBlockDefinedMatcher.h
\ No newline at end of file
../../Expecta/src/EXPDefines.h
\ No newline at end of file
../../Expecta/src/EXPDoubleTuple.h
\ No newline at end of file
../../Expecta/src/EXPExpect.h
\ No newline at end of file
../../Expecta/src/EXPFloatTuple.h
\ No newline at end of file
../../Expecta/src/EXPMatcher.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatcherHelpers.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beCloseTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beFalsy.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beGreaterThan.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beGreaterThanOrEqualTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beIdenticalTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beInTheRangeOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beInstanceOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beKindOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beLessThan.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beLessThanOrEqualTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beNil.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beSubclassOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beSupersetOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beTruthy.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+beginWith.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+conformTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+contain.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+endWith.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+equal.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+haveCountOf.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+notify.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+raise.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+raiseWithReason.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers+respondTo.h
\ No newline at end of file
../../Expecta/src/matchers/EXPMatchers.h
\ No newline at end of file
../../Expecta/src/EXPUnsupportedObject.h
\ No newline at end of file
../../Expecta/src/Expecta.h
\ No newline at end of file
../../Expecta/src/ExpectaSupport.h
\ No newline at end of file
../../Expecta/src/NSObject+Expecta.h
\ No newline at end of file
../../Expecta/src/NSValue+Expecta.h
\ No newline at end of file
../../../Masonry/MASCompositeConstraint.h
\ No newline at end of file
../../../Masonry/MASConstraint+Private.h
\ No newline at end of file
../../../Masonry/MASConstraint.h
\ No newline at end of file
../../../Masonry/MASConstraintMaker.h
\ No newline at end of file
../../../Masonry/MASLayoutConstraint.h
\ No newline at end of file
../../../Masonry/MASUtilities.h
\ No newline at end of file
../../../Masonry/MASViewAttribute.h
\ No newline at end of file
../../../Masonry/MASViewConstraint.h
\ No newline at end of file
../../../Masonry/Masonry.h
\ No newline at end of file
../../../Masonry/NSArray+MASAdditions.h
\ No newline at end of file
../../../Masonry/NSArray+MASShorthandAdditions.h
\ No newline at end of file
../../../Masonry/NSLayoutConstraint+MASDebugAdditions.h
\ No newline at end of file
../../../Masonry/View+MASAdditions.h
\ No newline at end of file
../../../Masonry/View+MASShorthandAdditions.h
\ No newline at end of file
... ... @@ -8,6 +8,6 @@
@property (nonatomic, assign) double *values;
@property (nonatomic, assign) size_t size;
- (id)initWithDoubleValues:(double *)values size:(size_t)size;
- (instancetype)initWithDoubleValues:(double *)values size:(size_t)size NS_DESIGNATED_INITIALIZER;
@end
... ...
... ... @@ -4,7 +4,7 @@
@synthesize values = _values, size = _size;
- (id)initWithDoubleValues:(double *)values size:(size_t)size {
- (instancetype)initWithDoubleValues:(double *)values size:(size_t)size {
if ((self = [super init])) {
self.values = malloc(sizeof(double) * size);
memcpy(self.values, values, sizeof(double) * size);
... ...
... ... @@ -9,6 +9,7 @@
char *_fileName;
BOOL _negative;
BOOL _asynchronous;
NSTimeInterval _timeout;
}
@property(nonatomic, copy) EXPIdBlock actualBlock;
... ... @@ -18,14 +19,16 @@
@property(nonatomic) const char *fileName;
@property(nonatomic) BOOL negative;
@property(nonatomic) BOOL asynchronous;
@property(nonatomic) NSTimeInterval timeout;
@property(nonatomic, readonly) EXPExpect *to;
@property(nonatomic, readonly) EXPExpect *toNot;
@property(nonatomic, readonly) EXPExpect *notTo;
@property(nonatomic, readonly) EXPExpect *will;
@property(nonatomic, readonly) EXPExpect *willNot;
@property(nonatomic, readonly) EXPExpect *(^after)(NSTimeInterval timeInterval);
- (id)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName;
- (instancetype)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName NS_DESIGNATED_INITIALIZER;
+ (EXPExpect *)expectWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName;
- (void)applyMatcher:(id<EXPMatcher>)matcher;
... ... @@ -37,6 +40,6 @@
EXPExpect *_expectation;
SEL _selector;
}
- (id)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector;
- (void (^)(void))dispatch;
- (instancetype)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector NS_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly, copy) void (^dispatch)(void);
@end
... ...
... ... @@ -14,23 +14,26 @@
toNot,
notTo,
will,
willNot;
willNot,
after;
@synthesize
actualBlock=_actualBlock,
testCase=_testCase,
negative=_negative,
asynchronous=_asynchronous,
timeout=_timeout,
lineNumber=_lineNumber,
fileName=_fileName;
- (id)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName {
- (instancetype)initWithActualBlock:(id)actualBlock testCase:(id)testCase lineNumber:(int)lineNumber fileName:(const char *)fileName {
self = [super init];
if(self) {
self.actualBlock = actualBlock;
self.testCase = testCase;
self.negative = NO;
self.asynchronous = NO;
self.timeout = [Expecta asynchronousTestTimeout];
self.lineNumber = lineNumber;
self.fileName = fileName;
}
... ... @@ -39,7 +42,7 @@
- (void)dealloc
{
self.actualBlock = nil;
_actualBlock = nil;
[super dealloc];
}
... ... @@ -71,6 +74,17 @@
return self.will.toNot;
}
- (EXPExpect *(^)(NSTimeInterval))after
{
EXPExpect * (^block)(NSTimeInterval) = [^EXPExpect *(NSTimeInterval timeout) {
self.asynchronous = YES;
self.timeout = timeout;
return self;
} copy];
return [block autorelease];
}
#pragma mark -
- (id)actual {
... ... @@ -98,7 +112,7 @@
} else {
BOOL matchResult = NO;
if(self.asynchronous) {
NSTimeInterval timeOut = [Expecta asynchronousTestTimeout];
NSTimeInterval timeOut = self.timeout;
NSDate *expiryDate = [NSDate dateWithTimeIntervalSinceNow:timeOut];
while(1) {
matchResult = [matcher matches:*actual];
... ... @@ -164,7 +178,7 @@
@implementation EXPDynamicPredicateMatcher
- (id)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector
- (instancetype)initWithExpectation:(EXPExpect *)expectation selector:(SEL)selector
{
if ((self = [super init])) {
_expectation = expectation;
... ...
... ... @@ -8,6 +8,6 @@
@property (nonatomic, assign) float *values;
@property (nonatomic, assign) size_t size;
- (id)initWithFloatValues:(float *)values size:(size_t)size;
- (instancetype)initWithFloatValues:(float *)values size:(size_t)size NS_DESIGNATED_INITIALIZER;
@end
... ...
... ... @@ -4,7 +4,7 @@
@synthesize values = _values, size = _size;
- (id)initWithFloatValues:(float *)values size:(size_t)size {
- (instancetype)initWithFloatValues:(float *)values size:(size_t)size {
if ((self = [super init])) {
self.values = malloc(sizeof(float) * size);
memcpy(self.values, values, sizeof(float) * size);
... ... @@ -30,6 +30,16 @@
return NO;
}
- (NSUInteger)hash
{
NSUInteger prime = 31;
NSUInteger hash = 0;
for (int i=0; i<self.size; i++) {
hash = prime * hash + (NSUInteger)self.values[i];
}
return hash;
}
- (NSString *)description {
if (self.size == 2) {
return [NSString stringWithFormat:@"Float tuple: {%f, %f}", self.values[0], self.values[1]];
... ...
... ... @@ -6,6 +6,6 @@
@property (nonatomic, retain) NSString *type;
- (id)initWithType:(NSString *)type;
- (instancetype)initWithType:(NSString *)type NS_DESIGNATED_INITIALIZER;
@end
... ...
... ... @@ -4,7 +4,7 @@
@synthesize type=_type;
- (id)initWithType:(NSString *)type {
- (instancetype)initWithType:(NSString *)type {
self = [super init];
if(self) {
self.type = type;
... ...
#import <Foundation/Foundation.h>
//! Project version number for Expecta.
FOUNDATION_EXPORT double ExpectaVersionNumber;
//! Project version string for Expecta.
FOUNDATION_EXPORT const unsigned char ExpectaVersionString[];
#import <Expecta/ExpectaObject.h>
#import <Expecta/ExpectaSupport.h>
#import <Expecta/EXPMatchers.h>
// Enable shorthand by default
#define expect(...) EXP_expect((__VA_ARGS__))
#define failure(...) EXP_failure((__VA_ARGS__))
\ No newline at end of file
... ...
#import <Foundation/Foundation.h>
#import "ExpectaSupport.h"
#define EXPObjectify(value) _EXPObjectify(@encode(__typeof__((value))), (value))
#define EXP_expect(actual) _EXP_expect(self, __LINE__, __FILE__, ^id{ return EXPObjectify((actual)); })
#define EXPMatcherInterface(matcherName, matcherArguments) _EXPMatcherInterface(matcherName, matcherArguments)
#define EXPMatcherImplementationBegin(matcherName, matcherArguments) _EXPMatcherImplementationBegin(matcherName, matcherArguments)
#define EXPMatcherImplementationEnd _EXPMatcherImplementationEnd
#define EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments) _EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments)
#import "EXPMatchers.h"
#ifdef EXP_SHORTHAND
# define expect(actual) EXP_expect((actual))
#endif
#define EXP_failure(message) EXPFail(self, __LINE__, __FILE__, message)
#ifdef EXP_OLD_SYNTAX
# import "EXPBackwardCompatibility.h"
#endif
@interface Expecta : NSObject
... ...
#import "Expecta.h"
#import "ExpectaObject.h"
@implementation Expecta
... ...
#import "EXPExpect.h"
#import "EXPBlockDefinedMatcher.h"
#ifdef __cplusplus
extern "C" {
#endif
id _EXPObjectify(const char *type, ...);
EXPExpect *_EXP_expect(id testCase, int lineNumber, const char *fileName, EXPIdBlock actualBlock);
... ... @@ -54,3 +58,16 @@ EXPFixCategoriesBug(EXPMatcher##matcherName##Matcher); \
return _EXP_autorelease(matcherBlock); \
} \
@end
#define _EXPMatcherAliasImplementation(newMatcherName, oldMatcherName, matcherArguments) \
EXPFixCategoriesBug(EXPMatcher##newMatcherName##Matcher); \
@implementation EXPExpect (newMatcherName##Matcher) \
@dynamic newMatcherName;\
- (void(^) matcherArguments) newMatcherName { \
return [self oldMatcherName]; \
}\
@end
#ifdef __cplusplus
}
#endif
... ...
... ... @@ -7,12 +7,6 @@
#import "EXPDefines.h"
#import <objc/runtime.h>
@interface NSException (ExpectaSenTestFailure)
+ (NSException *)failureInFile:(NSString *)filename atLine:(int)lineNumber withDescription:(NSString *)formatString, ...;
@end
@interface NSObject (ExpectaXCTestRecordFailure)
// suppress warning
... ... @@ -26,44 +20,44 @@ id _EXPObjectify(const char *type, ...) {
id obj = nil;
if(strcmp(type, @encode(char)) == 0) {
char actual = (char)va_arg(v, int);
obj = [NSNumber numberWithChar:actual];
obj = @(actual);
} else if(strcmp(type, @encode(_Bool)) == 0) {
_Static_assert(sizeof(_Bool) <= sizeof(int), "Expected _Bool to be subject to vararg type promotion");
_Bool actual = (_Bool)va_arg(v, int);
obj = [NSNumber numberWithBool:actual];
obj = @(actual);
} else if(strcmp(type, @encode(double)) == 0) {
double actual = (double)va_arg(v, double);
obj = [NSNumber numberWithDouble:actual];
obj = @(actual);
} else if(strcmp(type, @encode(float)) == 0) {
float actual = (float)va_arg(v, double);
obj = [NSNumber numberWithFloat:actual];
obj = @(actual);
} else if(strcmp(type, @encode(int)) == 0) {
int actual = (int)va_arg(v, int);
obj = [NSNumber numberWithInt:actual];
obj = @(actual);
} else if(strcmp(type, @encode(long)) == 0) {
long actual = (long)va_arg(v, long);
obj = [NSNumber numberWithLong:actual];
obj = @(actual);
} else if(strcmp(type, @encode(long long)) == 0) {
long long actual = (long long)va_arg(v, long long);
obj = [NSNumber numberWithLongLong:actual];
obj = @(actual);
} else if(strcmp(type, @encode(short)) == 0) {
short actual = (short)va_arg(v, int);
obj = [NSNumber numberWithShort:actual];
obj = @(actual);
} else if(strcmp(type, @encode(unsigned char)) == 0) {
unsigned char actual = (unsigned char)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedChar:actual];
obj = @(actual);
} else if(strcmp(type, @encode(unsigned int)) == 0) {
unsigned int actual = (int)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedInt:actual];
obj = @(actual);
} else if(strcmp(type, @encode(unsigned long)) == 0) {
unsigned long actual = (unsigned long)va_arg(v, unsigned long);
obj = [NSNumber numberWithUnsignedLong:actual];
obj = @(actual);
} else if(strcmp(type, @encode(unsigned long long)) == 0) {
unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long);
obj = [NSNumber numberWithUnsignedLongLong:actual];
obj = @(actual);
} else if(strcmp(type, @encode(unsigned short)) == 0) {
unsigned short actual = (unsigned short)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedShort:actual];
obj = @(actual);
} else if(strstr(type, @encode(EXPBasicBlock)) != NULL) {
// @encode(EXPBasicBlock) returns @? as of clang 4.1.
// This condition must occur before the test for id/class type,
... ... @@ -113,14 +107,9 @@ void EXPFail(id testCase, int lineNumber, const char *fileName, NSString *messag
NSString *reason = [NSString stringWithFormat:@"%s:%d %@", fileName, lineNumber, message];
NSException *exception = [NSException exceptionWithName:@"Expecta Error" reason:reason userInfo:nil];
if(testCase && [testCase respondsToSelector:@selector(failWithException:)]) {
if([[(Class)objc_getMetaClass("NSException") class] instancesRespondToSelector:@selector(failureInFile:atLine:withDescription:)]) {
exception = [NSException failureInFile:[NSString stringWithUTF8String:fileName] atLine:lineNumber withDescription:message];
}
[testCase failWithException:exception];
} else if(testCase && [testCase respondsToSelector:@selector(recordFailureWithDescription:inFile:atLine:expected:)]){
if(testCase && [testCase respondsToSelector:@selector(recordFailureWithDescription:inFile:atLine:expected:)]){
[testCase recordFailureWithDescription:message
inFile:[NSString stringWithUTF8String:fileName]
inFile:@(fileName)
atLine:lineNumber
expected:NO];
} else {
... ... @@ -157,7 +146,7 @@ NSString *EXPDescribeObject(id obj) {
} else if([obj isKindOfClass:[NSDictionary class]]) {
NSMutableArray *arr = [NSMutableArray arrayWithCapacity:[obj count]];
for(id k in obj) {
id v = [obj objectForKey:k];
id v = obj[k];
[arr addObject:[NSString stringWithFormat:@"%@ = %@;",EXPDescribeObject(k), EXPDescribeObject(v)]];
}
description = [NSString stringWithFormat:@"{%@}", [arr componentsJoinedByString:@" "]];
... ... @@ -170,18 +159,18 @@ NSString *EXPDescribeObject(id obj) {
}
void EXP_prerequisite(EXPBoolBlock block) {
[[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setPrerequisiteBlock:block];
[[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setPrerequisiteBlock:block];
}
void EXP_match(EXPBoolBlock block) {
[[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setMatchBlock:block];
[[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setMatchBlock:block];
}
void EXP_failureMessageForTo(EXPStringBlock block) {
[[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setFailureMessageForToBlock:block];
[[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setFailureMessageForToBlock:block];
}
void EXP_failureMessageForNotTo(EXPStringBlock block) {
[[[[NSThread currentThread] threadDictionary] objectForKey:@"EXP_currentMatcher"] setFailureMessageForNotToBlock:block];
[[[NSThread currentThread] threadDictionary][@"EXP_currentMatcher"] setFailureMessageForNotToBlock:block];
}
... ...
... ... @@ -6,5 +6,5 @@ EXPMatcherInterface(beIdenticalTo, (void *expected)); // to aid code completion
#if __has_feature(objc_arc)
#define beIdenticalTo(expected) _beIdenticalTo((__bridge void*)expected)
#else
#define beIdenticalTo _beIdenticalTo
#define beIdenticalTo(expected) _beIdenticalTo(expected)
#endif
... ...
#import "EXPMatchers+equal.h"
#import "EXPMatcherHelpers.h"
EXPMatcherImplementationBegin(beIdenticalTo, (void *expected)) {
EXPMatcherImplementationBegin(_beIdenticalTo, (void *expected)) {
match(^BOOL{
if(actual == expected) {
return YES;
... ...
#import "Expecta.h"
EXPMatcherInterface(beInstanceOf, (Class expected));
EXPMatcherInterface(beAnInstanceOf, (Class expected));
EXPMatcherInterface(beMemberOf, (Class expected));
EXPMatcherInterface(beAMemberOf, (Class expected));
... ...
... ... @@ -25,3 +25,7 @@ EXPMatcherImplementationBegin(beInstanceOf, (Class expected)) {
});
}
EXPMatcherImplementationEnd
EXPMatcherAliasImplementation(beAnInstanceOf, beInstanceOf, (Class expected));
EXPMatcherAliasImplementation(beMemberOf, beInstanceOf, (Class expected));
EXPMatcherAliasImplementation(beAMemberOf, beInstanceOf, (Class expected));
... ...
#import "Expecta.h"
EXPMatcherInterface(beKindOf, (Class expected));
EXPMatcherInterface(beAKindOf, (Class expected));
... ...
... ... @@ -25,3 +25,5 @@ EXPMatcherImplementationBegin(beKindOf, (Class expected)) {
});
}
EXPMatcherImplementationEnd
EXPMatcherAliasImplementation(beAKindOf, beKindOf, (Class expected));
... ...
#import "Expecta.h"
EXPMatcherInterface(beNil, (void));
#define beNull beNil
EXPMatcherInterface(beNull, (void));
... ...
... ... @@ -14,3 +14,5 @@ EXPMatcherImplementationBegin(beNil, (void)) {
});
}
EXPMatcherImplementationEnd
EXPMatcherAliasImplementation(beNull, beNil, (void));
... ...
#import "Expecta.h"
EXPMatcherInterface(beSubclassOf, (Class expected));
EXPMatcherInterface(beASubclassOf, (Class expected));
... ...
... ... @@ -25,3 +25,5 @@ EXPMatcherImplementationBegin(beSubclassOf, (Class expected)) {
});
}
EXPMatcherImplementationEnd
EXPMatcherAliasImplementation(beASubclassOf, beSubclassOf, (Class expected));
... ...