Routing of AssertError messages
Tejas
notrealemail at gmail.com
Sat Jul 31 12:32:06 UTC 2021
On Saturday, 31 July 2021 at 12:03:49 UTC, DLearner wrote:
> Hi
>
> This may be due to Windows, not DMD.
>
> Please see code below (held in test.d):
>
> ```
> void main() {
> import std.stdio;
>
> writeln("Test");
> assert(false, "TestAssert");
> }
> ```
> `
> dmd -i -run test.d
> `
> results in both "Test" and the "TestAssert" string (and trace)
> being routed to screen.
>
> But
> `
> dmd -i -run test.d > op.txt
> `
> results in only "Test" going into op.txt, the "TestAssert"
> string (and trace) being routed to screen as before.
>
> I expected both "Test" and the "TestAssert" string (and trace)
> to go into op.txt.
>
> The idea was to use op.txt as documentation of a successful
> test of the "TestAssert" string.
>
> Best regards
Please read the docs that jfronden referred to.
If you want a quick hack, use this:
```d
const(char)[] falseAssertMsg(string s){
writeln(s);
return "";
}
void main() {
import std.stdio;
writeln("Test");
assert(false, falseAssertMsg("TestAssert failed in
main()"));
}
```
There should be a better way of doing this though.
More information about the Digitalmars-d-learn
mailing list