unittest "name" {}

ProtectAndHide ProtectAndHide at gmail.com
Fri Feb 17 06:39:21 UTC 2023


On Thursday, 16 February 2023 at 15:36:25 UTC, Steven 
Schveighoffer wrote:
>
> I actually prefer without the quotes. Why? Because it matches 
> what we currently do:
>
> struct foo
> class bar
> unittest baz
>
> In addition, if you make it a string, since D has CTFE, this is 
> going to get confusing:
>
> sneaky.d:
> enum Johnny = "Freddy";
>
> othermodule.d:
>
> unittest Johnny {
> }
>
> "unittest Freddy failed"
>
> user: huh?
>
> So you have to come up with a name that has no spaces. Are you 
> a programmer or not?
>
> I would couch this by saying, I don't really think we need 
> anything here. The @("Johnny") is good enough for me. In fact, 
> I'm fine without labeling unittests at all, and just looking at 
> the file/line of the failed tests.
>
> -Steve

The litmus test for how to go about naming unittests should be 
what you would do if you didn't know how to do it.

int myInt
struct myStruct
class myClass
unittest myUnitTest (most people would automatically default to 
this, is my guess)

unittest @myUnitTest (on what basis would people automatically 
think that this is how to do it?

unittest "my unit test" (again, on what basis would people 
automatically think that this is how to do it?

It seems like a simple proposition with a simple for the 
programmer to do it.

Now make the language work for the programmer please, and not the 
other way around.





More information about the Digitalmars-d mailing list