Lookahead in unittest

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 10 09:32:11 PDT 2017


On Wednesday, 10 May 2017 at 16:09:06 UTC, Raiderium wrote:
> I can't figure out if this is intended behaviour.

It is. A unittest is a function, and in functions, all 
declarations must be defined before used (just like local 
variables).

Sometimes, you can wrap it in a struct:

unittest {
   struct Decls {
     // put your decls here
   }

   with(Decls()) {
    // call funcs here
   }
}


More information about the Digitalmars-d-learn mailing list