Created
August 14, 2014 23:47
-
-
Save drodriguez/23e7e24b597f9a15134f to your computer and use it in GitHub Desktop.
Better Kiwi?
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
#import "Kiwi.h" | |
#define KWPasteX(x, y) x ## y | |
#define KWPaste(x, y) KWPasteX(x, y) | |
#define KWMetaMacro(...) \ | |
if (0) \ | |
KWPaste(finished, __LINE__): ; \ | |
else \ | |
for (KWVoidBlock KWPaste(block, __LINE__) = nil;;) \ | |
if (1) \ | |
goto KWPaste(body, __LINE__); \ | |
else \ | |
while (1) \ | |
if (1) { \ | |
__VA_ARGS__; \ | |
goto KWPaste(finished, __LINE__); \ | |
} else \ | |
KWPaste(body, __LINE__): \ | |
KWPaste(block, __LINE__) = ^ | |
#define KWMetaMacro0(func) KWMetaMacro(func(KWPaste(block, __LINE__))) | |
#define KWMetaMacro1(func, description) KWMetaMacro(func(description, KWPaste(block, __LINE__))) | |
#define Describe(description) KWMetaMacro1(describe, description) | |
#define Context(description) KWMetaMacro1(context, description) | |
#define BeforeAll KWMetaMacro0(beforeAll) | |
#define AfterAll KWMetaMacro0(afterAll) | |
#define BeforeEach KWMetaMacro0(beforeEach) | |
#define AfterEach KWMetaMacro0(afterEach) | |
#define It(description) KWMetaMacro1(it, description) | |
SPEC_BEGIN(MySpec) | |
Describe(@"Something") { | |
It(@"should foo") { | |
}; | |
Context(@"wadus") { | |
BeforeAll { | |
}; | |
AfterAll { | |
}; | |
BeforeEach { | |
}; | |
AfterEach { | |
}; | |
It(@"should bar") { | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment