digitalmars.dip.development - Statement Unittest [DRAFT]
- monkyyy (8/8) Oct 15 A module-level unittest statement( uses `()` instead of `{}`) for
- Paul Backus (20/21) Oct 15 For "Prior Work", I'd say the most obvious thing to cite is the
- Guillaume Piolat (3/11) Oct 17 This is a pretty cool idea.
- Sharif yt (5/19) Nov 19 Agreed! Module-level unittest with optional messages adds
A module-level unittest statement( uses `()` instead of `{}`) for single asserts , with an optional string message ```d unittest(1==1); unittest(1==1,"math broke"); ``` https://gist.github.com/crazymonkyyy/2afa7ae1402cd246fb98bdb86dd19605
Oct 15
On Tuesday, 15 October 2024 at 14:37:24 UTC, monkyyy wrote:https://gist.github.com/crazymonkyyy/2afa7ae1402cd246fb98bdb86dd19605For "Prior Work", I'd say the most obvious thing to cite is the shortened syntax for `in`, `out`, and `invariant` contracts: ```d // Short versions in (n > 0); out (ret; ret !is null); invariant (start <= end); // Long versions in { assert(n > 0); } out (ret) { assert(ret !is null); } invariant { assert( start <= end); } ``` Spec links: * [Function contracts][1] * [Struct invariants][2] * [Class invariants][3] [1]: https://dlang.org/spec/function.html#contracts [2]: https://dlang.org/spec/struct.html#Invariant [3]: https://dlang.org/spec/class.html#invariants
Oct 15
On Tuesday, 15 October 2024 at 14:37:24 UTC, monkyyy wrote:A module-level unittest statement( uses `()` instead of `{}`) for single asserts , with an optional string message ```d unittest(1==1); unittest(1==1,"math broke"); ``` https://gist.github.com/crazymonkyyy/2afa7ae1402cd246fb98bdb86dd19605This is a pretty cool idea. unittest being one of the big win of D, why not have more of it.
Oct 17
On Thursday, 17 October 2024 at 23:48:35 UTC, Guillaume Piolat wrote:On Tuesday, 15 October 2024 at 14:37:24 UTC, monkyyy wrote:Agreed! Module-level unittest with optional messages adds flexibility and simplicity to D’s testing framework—definitely a cool way to enhance one of its standout features.A module-level unittest statement( uses `()` instead of `{}`) for single asserts , with an optional string message ```d unittest(1==1); unittest(1==1,"math broke"); ``` https://gist.github.com/crazymonkyyy/2afa7ae1402cd246fb98bdb86dd19605This is a pretty cool idea. unittest being one of the big win of D, why not have more of it.
Nov 19