Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter let types #528

Merged
merged 2 commits into from
Jun 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Classes/Core/KWExample.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ void pendingWithCallSite(KWCallSite *aCallSite, NSString *aDescription, void (^b
variable in a `beforeAll` block, as its value is undefined at this point.
*/
void let(id name, id (^block)(void)); // coax Xcode into autocompleting
#define let(var, args...) \
__block id var = nil; \
let_(KW_LET_REF(var), #var, ## args)
#define let(var, ...) \
__block __typeof__((__VA_ARGS__)()) var = nil; \
let_(KW_LET_REF(var), #var, __VA_ARGS__)

#define PRAGMA(x) _Pragma (#x)
#define PENDING(x) PRAGMA(message ( "Pending: " #x ))
Expand Down
12 changes: 10 additions & 2 deletions Tests/KWFunctionalTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "Kiwi.h"
#import "KiwiTestConfiguration.h"
#import "TestClasses.h"

@interface KWExampleSuiteBuilder ()

Expand Down Expand Up @@ -73,7 +74,7 @@ @interface KWExampleSuiteBuilder ()
NSMutableArray *unFocusedContextCalls = @[ @"OuterTestCase", @"BeforeAll", @"AfterAll", @"BeforeEach", @"AfterEach"
].mutableCopy;

[[KWExampleSuiteBuilder sharedExampleSuiteBuilder] setFocusedCallSite:[KWCallSite callSiteWithFilename:@"KWFunctionalTests.m" lineNumber:84]];
[[KWExampleSuiteBuilder sharedExampleSuiteBuilder] setFocusedCallSite:[KWCallSite callSiteWithFilename:@"KWFunctionalTests.m" lineNumber:85]];

describe(@"UnFocusedContext", ^{
it(@"OuterTestCase", ^{ [unFocusedContextCalls removeObject:@"OuterTestCase"]; });
Expand Down Expand Up @@ -116,7 +117,7 @@ @interface KWExampleSuiteBuilder ()

NSMutableArray *unFocusedItCalls = @[@"UnFocusedTestCase"].mutableCopy;

[[KWExampleSuiteBuilder sharedExampleSuiteBuilder] setFocusedCallSite:[KWCallSite callSiteWithFilename:@"KWFunctionalTests.m" lineNumber:122]];
[[KWExampleSuiteBuilder sharedExampleSuiteBuilder] setFocusedCallSite:[KWCallSite callSiteWithFilename:@"KWFunctionalTests.m" lineNumber:123]];

describe(@"FocusedIt", ^{
it(@"FocusedTestCase", ^{ [focusedItCalls removeObject:@"FocusedTestCase"]; });
Expand Down Expand Up @@ -204,6 +205,13 @@ @interface KWExampleSuiteBuilder ()
});
});

describe(@"using property notation", ^{
let(cruiser, ^{ return [[Cruiser alloc] initWithCallsign:@"let"]; });
specify(^{
[[cruiser.callsign should] equal:@"let"];
});
});

SPEC_END

SPEC_BEGIN(NilMatchers)
Expand Down