There must be module with test assertions in Phobos
Petar
Petar
Thu Mar 30 17:22:39 UTC 2023
On Thursday, 30 March 2023 at 17:01:26 UTC, Dmytro Katyukha wrote:
> Hi all,
> [..]
Hi! Are you aware of the `-checkaction=context` compiler flag?
Give it a shot:
```d
unittest {
int x = 0, y = 5;
assert(x == y);
}
```
```sh
dmd -main -unittest -checkaction=context -run ./example.d
```
```
onlineapp.d(3): [unittest] 0 != 5
1/1 modules FAILED unittests
```
Test on [run.dlang.io][0].
This is not an argument against a dedicated assertion module, but
I think it's good to be aware what can be achieved at the
compiler/runtime level vs library level.
[0]:
https://run.dlang.io/?compiler=dmd&source=unittest%20%7B%0A%20%20%20%20int%20x%20%3D%200,%20y%20%3D%205;%0A%20%20%20%20assert(x%20%3D%3D%20y);%0A%7D%0A&args=-unittest%20-checkaction%3Dcontext%20-main
More information about the Digitalmars-d
mailing list