Re: Lookahead in unittest

2017-05-14 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, May 13, 2017 at 12:39:43PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: > On 5/12/17 5:46 PM, H. S. Teoh via Digitalmars-d-learn wrote: [...] > > This advice, unfortunately, needs to be tempered with caution about > > namespace pollution and accidental dependency of things

Re: Lookahead in unittest

2017-05-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/17 5:46 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] Note, you can achieve what you want with version(unittest): version(unittest) { class A { B b; } class B { } } unittest {

Re: Lookahead in unittest

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 12, 2017 14:46:30 H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via > Digitalmars-d-learn wrote: [...] > > > Note, you can achieve what you want with version(unittest): > > > > version(unittest) > > { > > > >class A {

Re: Lookahead in unittest

2017-05-12 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] > Note, you can achieve what you want with version(unittest): > > version(unittest) > { >class A { B b; } >class B { } > } > > unittest > { >// use A and B here > } [...] This

Re: Lookahead in unittest

2017-05-12 Thread pineapple via Digitalmars-d-learn
On Friday, 12 May 2017 at 21:23:23 UTC, Steven Schveighoffer wrote: Note, you can achieve what you want with version(unittest): Please prefer `private version(unittest){...}` if the module might be imported by someone else's code, as to not pollute it with unneeded symbols

Re: Lookahead in unittest

2017-05-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/10/17 12:53 PM, Raiderium wrote: On Wednesday, 10 May 2017 at 16:32:11 UTC, Adam D. Ruppe wrote: 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

Re: Lookahead in unittest

2017-05-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-10 18:17, Stefan Koch wrote: It looks like this unitest-test block are treated like a function. unittest blocks are lowered to functions. -- /Jacob Carlborg

Re: Lookahead in unittest

2017-05-10 Thread Raiderium via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 16:32:11 UTC, Adam D. Ruppe wrote: 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

Re: Lookahead in unittest

2017-05-10 Thread Adam D. Ruppe via Digitalmars-d-learn
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 {

Re: Lookahead in unittest

2017-05-10 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 16:09:06 UTC, Raiderium wrote: Heyo, On 2.074.0, the following test fails with "Error: undefined identifier 'B' " unittest { class A { B b; } class B { } } I can't figure out if this is intended behaviour. It's making a template-heavy module

Lookahead in unittest

2017-05-10 Thread Raiderium via Digitalmars-d-learn
Heyo, On 2.074.0, the following test fails with "Error: undefined identifier 'B' " unittest { class A { B b; } class B { } } I can't figure out if this is intended behaviour. It's making a template-heavy module difficult to test. Would appreciate any help. First post