On Thursday, 14 August 2014 at 02:04:09 UTC, Idan Arye wrote:
Well, there's nothing to test in abstract functions, is there?

I'm more concerned about the unit test appearing before the code, when the usual convention is to put the unit tests after the code they are testing...

There is precedence conceptually for putting unittests before code (TDD as an example of a technique that suggests unittests should be written first). Plus, in some ways it makes sense that unittests come first because it shows you how to use the function in question. I often look at unittests for examples of how to use code, almost like documentation (which also comes before the code).

Not to mention the fact that we'd have to come up with new syntax otherwise. The following is ambiguous:

    void blah(T)(...)
    in { ... }
    body { ... }
    unittest { ... }

Is the unittest
  1. part of the module and thus should only be run once
or is it
2. part of the templated function and should be run per instantiation?

Current behavior is 1. So it'd be really necessary to come up with some new, unambiguous syntax to put the unittest after the function. Whereas the current proposal doesn't create an ambiguity and doesn't need new, special syntax to perform this task.

Reply via email to