Thread overview | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 29, 2017 Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found. Obviously, this means that no error will be found in unittests blocks. That can contain pretty much anything that lex, so it's even more lax than what's allowed inside a static if. Is that an acceptable tradeof ? |
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 29/03/2017 12:16 PM, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable
> to skip parsing altogether, just lexing and counting braces until the
> matching closing brace is found.
>
> Obviously, this means that no error will be found in unittests blocks.
> That can contain pretty much anything that lex, so it's even more lax
> than what's allowed inside a static if.
>
> Is that an acceptable tradeof ?
I see no reason to not to treat it as:
version(unittest) {
void func_xxxx() {
...
}
}
Which is basically what you said.
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Wednesday, 29 March 2017 at 11:22:59 UTC, rikki cattermole wrote:
> Which is basically what you said.
It isn't. version needs to be parsed and thus, grammatically valid.
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On 29/03/2017 1:16 PM, deadalnix wrote:
> On Wednesday, 29 March 2017 at 11:22:59 UTC, rikki cattermole wrote:
>> Which is basically what you said.
>
> It isn't. version needs to be parsed and thus, grammatically valid.
Hmm, well that is another thing that could be disabled to shave some time off the build times I suppose.
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
>
> Obviously, this means that no error will be found in unittests blocks. That can contain pretty much anything that lex, so it's even more lax than what's allowed inside a static if.
>
> Is that an acceptable tradeof ?
I would not do this trade off,
It's highly surprising since no other language feature works that way.
Also parsing is rather cheap.
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
Sorry, is this not already the case?
$ dmd test.d
$ cat test.d
void main()
{
import std.stdio;
writeln("Hello, world!");
}
unittest
{
foo bar {} baz more-syntax!errors)blah
}
$ dmd test.d
$ ./test
Hello, world!
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On Wednesday, 29 March 2017 at 19:32:50 UTC, Vladimir Panteleev wrote:
> On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
>
> Sorry, is this not already the case?
>
> $ dmd test.d
> $ cat test.d
> void main()
> {
> import std.stdio;
> writeln("Hello, world!");
> }
>
>
> unittest
> {
> foo bar {} baz more-syntax!errors)blah
> }
> $ dmd test.d
> $ ./test
> Hello, world!
Surprise!
|
March 29, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On Wednesday, 29 March 2017 at 19:32:50 UTC, Vladimir Panteleev wrote: > On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote: >> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found. > > Sorry, is this not already the case? https://github.com/dlang/dmd/pull/4704 |
March 30, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>
> Is that an acceptable tradeof ?
I would consider this harmful... The spec already states this about unit tests, so I'd guess the decision was taken in the past conscientiously.
If you're worried about compilation time, you can always define your unit tests in separate files that are included for compilation only when needed.
|
March 30, 2017 Re: Is it acceptable to not parse unittest blocks when unittests are disabled ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to XavierAP | On Thursday, 30 March 2017 at 06:53:47 UTC, XavierAP wrote:
> On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>>
>> Is that an acceptable tradeof ?
>
> I would consider this harmful... The spec already states this about unit tests, so I'd guess the decision was taken in the past conscientiously.
>
> If you're worried about compilation time, you can always define your unit tests in separate files that are included for compilation only when needed.
Why is it harmful (actually asking, not telling you you're wrong)? I thought we were going to use a pay for what you use philosophy, if a unit test is not run then why is it paid for?
|
Copyright © 1999-2021 by the D Language Foundation