Re: unittest under betterC

2023-06-06 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:22:45 UTC, Ernesto Castellotti wrote: [...] It's not so easy to deal automatically in case of multiple modules _multiple modules_ The following code, in a batch (.bat) file, works for me: ``` @echo off :loop if [%1]==[] goto loopexit type .\%1.d > .\__temp_%1.d ech

Re: unittest under betterC

2023-06-05 Thread Ernesto Castellotti via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:14:31 UTC, DLearner wrote: On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote: [...] Thank you for the link, can confirm that: ``` int foo() { [...] It's not so easy to deal automatically in case of multiple modules

Re: unittest under betterC

2023-06-05 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote: [...] The docs say it should work: https://dlang.org/spec/betterc.html#unittests [...] Thank you for the link, can confirm that: ``` int foo() { return 4; } unittest { assert(foo() != 4, "!= Assert triggered."); assert(fo

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:29:35 UTC, Richard (Rikki) Andrew Cattermole wrote: On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you prob

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work: https://dlang.org/spec/betterc.html#unittests So eith

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work: https://dla

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/06/2023 2:16 AM, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test If you as the user disable key components required for the language to fully work, its a you problem,

Re: unittest under betterC

2023-06-05 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 5 June 2023 at 11:41:08 UTC, Richard (Rikki) Andrew Cattermole wrote: On 05/06/2023 3:42 PM, ryuukk_ wrote: I don't know how all this works, but the runtime shouldn't know about tests, imagine if you ship a game, and the player can run all the unittests, that doesn't make sense Cur

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/06/2023 3:42 PM, ryuukk_ wrote: I don't know how all this works, but the runtime shouldn't know about tests, imagine if you ship a game, and the player can run all the unittests, that doesn't make sense Currently that is not possible. When you turn on unittests to be compiled in, that r

Re: unittest under betterC

2023-06-05 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 03:42:20 UTC, ryuukk_ wrote: [...] I don't know how all this works, ... For what it is worth, running _both_ the above code fragments with: ``` dmd -main -unittest -i -run foo ``` (ie removing the -betterC flag) produces: ``` foo.d(8): [unittest] != Assert triggere

Re: unittest under betterC

2023-06-04 Thread ryuukk_ via Digitalmars-d-learn
On Sunday, 4 June 2023 at 22:14:59 UTC, Richard (Rikki) Andrew Cattermole wrote: On 05/06/2023 9:20 AM, ryuukk_ wrote: Then this needs to be fixed asap, unittest needs to work for the flags user will use There is nothing to fix. You literally do not have any of the druntime code needed to ha

Re: unittest under betterC

2023-06-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/06/2023 9:20 AM, ryuukk_ wrote: Then this needs to be fixed asap, unittest needs to work for the flags user will use There is nothing to fix. You literally do not have any of the druntime code needed to handle ModuleInfo and hence call via it. Nor do you have the entry point handled f

Re: unittest under betterC

2023-06-04 Thread ryuukk_ via Digitalmars-d-learn
On Sunday, 4 June 2023 at 20:43:17 UTC, Richard (Rikki) Andrew Cattermole wrote: Unittests require some mechanism to execute them. Druntime provides this capability by default. You can do it manually by using ``__traits(getUnitTests)`` to get access to the symbols. Personally I just use full

Re: unittest under betterC

2023-06-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Unittests require some mechanism to execute them. Druntime provides this capability by default. You can do it manually by using ``__traits(getUnitTests)`` to get access to the symbols. Personally I just use full D for unittests.

unittest under betterC

2023-06-04 Thread DLearner via Digitalmars-d-learn
Neither: ``` extern(C) int foo() { return 4; } unittest { assert(foo() != 4, "!= Assert triggered."); assert(foo() == 4, "== Assert triggered."); } ``` Nor: ``` int foo() { return 4; } unittest { assert(foo() != 4, "!= Assert triggered."); assert(foo() == 4, "== Assert tr