3 ms·
And then in D it's built-in to the compiler so it's a 1 liner of sorts: unittest { ... } and they all run during compilation. https://dlang.org/spec/unittest
by giancarlostoro 8y ago
And then in D it's built-in to the compiler so it's a 1 liner of sorts:
unittest { ... }
and they all run during compilation.
https://dlang.org/spec/unittest.html https://dlang.org/spec/unittest.html
- tonyedgecombe 8y agoI'm surprised that isn't used in other languages, having the test right next to the code seems such a good idea.
- giancarlostoro 8y agoRust went this path too, there's something I love about having unittesting readily available. I can choose to use it or not use it. My asserts are available to me as I so desire. Python too sorta has some unittesting in the standard library, but that's not a compiler level thing.
- blt 8y agowhat happens if you write a really slow test? is there some way to take advantage of the inbuilt console reporting, etc. without running them after every compile?
- giancarlostoro 8y agoIt's not compiled into your binary unless you want it to be. It's ran at compile time every time you compile, though I'm sure there's a flag to not run unit testing, and maybe with version() you might be able to block out the time ocnsuming tests. Not sure what you'd do in D that'd be so time consuming though. Edit: URL to version() docs: https://dlang.org/spec/version.html https://dlang.org/spec/version.html