Unittests on a module

2023-01-13 Thread DLearner via Digitalmars-d-learn
If unittest run without a main() being present, crashes on link 
error:

```
lld-link: error: subsystem must be defined
Error: linker exited with status 1
```

Is this intended?

It's not a problem to add temporary
```
void main() {

}
```
to the bottom of the module, but seems wrong as not then testing 
_exactly_ what is to be imported elsewhere.


Re: Unittests on a module

2023-01-13 Thread Dennis via Digitalmars-d-learn

On Friday, 13 January 2023 at 19:07:46 UTC, DLearner wrote:

Is this intended?


It is by design, though opinions differ on whether it's a good 
design.



It's not a problem to add temporary
```
void main() {

}
```
to the bottom of the module,


You can add the `-main` flag to make dmd automatically add such 
an empty main function when there isn't a `main` already.