automatic code examples in documentation
Tomek Sowiński
just at ask.me
Fri Oct 15 17:29:50 PDT 2010
Tomek Sowiński napisał:
> As I mentioned in bugzilla, it opens the opportunity to kill the unittest
> naming problem with the same stone:
>
> void foo();
>
> unittest(owner) {
> Log.info("Testing " ~ owner.stringof ~ "...");
> scope(exit) Log.info("Testing " ~ owner.stringof ~ " complete");
> }
>
> The syntax takes after the out(result) contract. 'owner' is an alias to
> the preceding symbol. The overall ROI looks positive, eh?
Nevermind. It's little better than:
unittest {
alias foo owner;
Log.info("Testing " ~ owner.stringof ~ "...");
scope(exit) Log.info("Testing " ~ owner.stringof ~ " complete");
}
There must be a way to make it all work elegantly with, say, an IDE's unittest runner, but I
won't find it posting at 2:28 a.m.
--
Tomek
More information about the Digitalmars-d
mailing list