Dynamic predicate matchers #15

wants to merge 18 commits into

2 participants


(sorry, this also includes the commits of my other pull request - not sure how to work around that).

The newest commits on this pull request add support for dynamic predicate matchers. You still need to define the matcher interfaces to satisfy the compiler but you don't need the corresponding matcher implementation as it will be handled at runtime.

Example from the test case:

@interface LightSwitch : NSObject
@property (nonatomic, assign, getter=isTurnedOn) BOOL turnedOn;

@implementation LightSwitch
@synthesize turnedOn;

EXPMatcherInterface(isTurnedOn, (void));
#define beTurnedOn isTurnedOn

@interface DynamicPredicateMatcherTest : SenTestCase

@implementation DynamicPredicateMatcherTest

- (void)test_CanUseObjectPredicatesAsBooleanMatchers
  LightSwitch *lightSwitch = [[LightSwitch alloc] init];

  lightSwitch.turnedOn = YES;


  lightSwitch.turnedOn = NO;


David Hart and others added some commits Mar 7, 2012
David Hart Fixed a false negative bug with asynchronous negatives
When expecting an asynchronous negative, if the matchBlock returns
true, we will return a fail before waiting the timeout. I modified the
asynchronous tests to fail with that bug and fixed the bug by taking
into account the negative in the asynchronous loop.
David Hart Improved the naming convention. 177811f
David Hart Added beCloseTo matcher. 6229f4e
David Hart Missing beCloseTo import 55f55ea
David Hart Renamed test classes to correspond to the new naming scheme. 7e7482d
David Hart Removed a ghost of the exception handling in the project file. 64b8a0e
David Hart Updated to README to show the new modifications b418527
David Hart Added the ability for the contain matcher to use any NSFastEnumeratio…
…n object.
David Hart Upgraded to Xcode 4.3 e48fc10
David Hart Fix ARC warning and avoid having to bridge id objects fcb91db
David Hart Added a beCountOf matcher for collections fa90b27
@lukeredpath lukeredpath Start to move towards supporting a generic protocol for matching.
The EXPRuntimeMatcher supports the existing method of defining matchers,
and moves matcher state out of the EXPExpect object.
@lukeredpath lukeredpath This seems like a better name for this class. 935bf00
@lukeredpath lukeredpath Make `applyMatcher:to:` actually depend solely on the EXPMatcher prot…

rather than the BlockDefinedMatcher implementation, by having BlockDefinedMatcher
actually implement the protocol.
@lukeredpath lukeredpath Added a test that demonstrates the use of a custom matcher class. 54343d4
@lukeredpath lukeredpath Make everything in the EXPMatcher protocol optional, except for matches: 9b11fb6
@lukeredpath lukeredpath Added support for dynamic predicate matchers.
We still need to define the matcher interface to satisfy the compiler 
but we don't need to do any matcher implementation as it can be handled
at runtime.
@lukeredpath lukeredpath Added notes on dynamic dispatch predicates to README 3206188
@petejkim petejkim closed this Mar 27, 2012
Specta / Expecta member

This is amazing. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment