D - named unittests
- Daniel Yokomiso (51/51) Nov 25 2002 Hi,
Hi, I think unittests should have an optional naming feature like: class A { void doA() { } void doA(int b) { } } class B : A { void doA() { } void doB() { } } unittest (A) { } unittest (A.doA) { } unittest (A.doA(int)) { } unittest (B) { } unittest (B.doA) { } unittest (B.doB) { } or something like that. Usually unittests are associated to classes, methods, or individual functions, via naming schemes. With this possibility any tool could extract named bits of tests from a module, and use it to create automatic documentation, or just show it to the user. It would be better than javadoc capabilities, a doc tool for D could include contracts and unittests when showing the documentation of a class, method or function. Another possibility would be allowing unittest declarations inside functions as: int sum(int left, int right) { unittest { assert(15 == sum(7 + 8)); } return left + right; } or int sum(int left, int right) unittest { assert(15 == sum(7 + 8)); } body { return left + right; } Best regards, Daniel Yokomiso. "When you want to change the world, you don't see the dawn by getting up early - you see it by not sleeping through the night."
Nov 25 2002