Created
August 27, 2013 22:58
-
-
Save zakky-dev/6360149 to your computer and use it in GitHub Desktop.
__traitsのgetMemberは継承したあとに使っても駄目らしい。
This file contains hidden or 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 std.stdio; | |
import std.conv; | |
class TestCase(string methodName) { | |
void run() { | |
__traits(getMember, this, methodName); | |
} | |
} | |
class WasRun(string methodName) : TestCase!(methodName) { | |
private bool wasRun; | |
this() { | |
this.wasRun = false; | |
} | |
private void testMethod() { | |
this.wasRun = true; | |
} | |
} | |
unittest { | |
auto test = new WasRun!("testMethod")(); | |
assert(! test.wasRun); | |
test.run(); | |
assert(test.wasRun); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TestCase::runの中で存在していないtestMethodを呼ぼうとするわけだし、これも当然。