Re: safe pure unittest

2014-10-30 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 07:53:34AM -0700, H. S. Teoh via Digitalmars-d-learn 
wrote:
 On Wed, Aug 13, 2014 at 03:03:14PM +0200, simendsjo via Digitalmars-d-learn 
 wrote:
  On 08/13/2014 02:50 PM, Dicebot wrote:
   On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote:
   This is the first time I've seen attributes on unittests:
   https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179
  
  
   Has this always been supported? I guess it's good practice to add
   these on unittests too, but does people even know about this
   feature? And are there any cons to doing this?
   
   unittest block is effectively just a special function declaration
   so all function attributes are applicable and act in a similar
   way.
   
   It is an extremely important idiom when you wan't to ensure
   specific properties of templated function that may be valid or not
   depending on template arguments. For example, function with output
   range may be @nogc or not depending if used output range type
   triggers GC. But you can mark with @nogc unittest that uses it
   with dummy output range to ensure that _nothing else_ allocated.
  
  Thanks.
  
  The unittest documentation notes that unittests are functions in one
  of the sentences, but nothing regarding attributes (except for
  private) is mentioned: http://dlang.org/unittest.html
 
 A PR to fix this would be greatly welcomed. ;-)
[...]

Ninja'd: https://github.com/D-Programming-Language/dlang.org/pull/685

;-)


T

-- 
Stop staring at me like that! It's offens... no, you'll hurt your eyes!


safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
This is the first time I've seen attributes on unittests:
https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179

Has this always been supported? I guess it's good practice to add these
on unittests too, but does people even know about this feature? And are
there any cons to doing this?


Re: safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
On 08/13/2014 02:50 PM, Dicebot wrote:
 On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote:
 This is the first time I've seen attributes on unittests:
 https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179


 Has this always been supported? I guess it's good practice to add these
 on unittests too, but does people even know about this feature? And are
 there any cons to doing this?
 
 unittest block is effectively just a special function declaration so all
 function attributes are applicable and act in a similar way.
 
 It is an extremely important idiom when you wan't to ensure specific
 properties of templated function that may be valid or not depending on
 template arguments. For example, function with output range may be @nogc
 or not depending if used output range type triggers GC. But you can mark
 with @nogc unittest that uses it with dummy output range to ensure that
 _nothing else_ allocated.

Thanks.

The unittest documentation notes that unittests are functions in one of
the sentences, but nothing regarding attributes (except for private) is
mentioned: http://dlang.org/unittest.html


Re: safe pure unittest

2014-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Aug 13, 2014 at 03:03:14PM +0200, simendsjo via Digitalmars-d-learn 
wrote:
 On 08/13/2014 02:50 PM, Dicebot wrote:
  On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote:
  This is the first time I've seen attributes on unittests:
  https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179
 
 
  Has this always been supported? I guess it's good practice to add
  these on unittests too, but does people even know about this
  feature? And are there any cons to doing this?
  
  unittest block is effectively just a special function declaration so
  all function attributes are applicable and act in a similar way.
  
  It is an extremely important idiom when you wan't to ensure specific
  properties of templated function that may be valid or not depending
  on template arguments. For example, function with output range may
  be @nogc or not depending if used output range type triggers GC. But
  you can mark with @nogc unittest that uses it with dummy output
  range to ensure that _nothing else_ allocated.
 
 Thanks.
 
 The unittest documentation notes that unittests are functions in one
 of the sentences, but nothing regarding attributes (except for
 private) is mentioned: http://dlang.org/unittest.html

A PR to fix this would be greatly welcomed. ;-)


T

-- 
Why do conspiracy theories always come from the same people??