Skip to content

Instantly share code, notes, and snippets.

@zakky-dev
Created August 27, 2013 22:58
Show Gist options
  • Save zakky-dev/6360149 to your computer and use it in GitHub Desktop.
Save zakky-dev/6360149 to your computer and use it in GitHub Desktop.
__traitsのgetMemberは継承したあとに使っても駄目らしい。
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);
}
@zakky-dev
Copy link
Author

TestCase::runの中で存在していないtestMethodを呼ぼうとするわけだし、これも当然。

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