digitalmars.D.learn - safe pure unittest
- simendsjo (5/5) Aug 13 2014 This is the first time I've seen attributes on unittests:
- Dicebot (11/18) Aug 13 2014 unittest block is effectively just a special function declaration
- simendsjo (5/23) Aug 13 2014 Thanks.
- H. S. Teoh via Digitalmars-d-learn (5/30) Aug 13 2014 A PR to fix this would be greatly welcomed. ;-)
- H. S. Teoh via Digitalmars-d-learn (7/36) Oct 30 2014 [...]
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?
Aug 13 2014
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.
Aug 13 2014
On 08/13/2014 02:50 PM, Dicebot wrote:On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: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.htmlThis 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.
Aug 13 2014
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:A PR to fix this would be greatly welcomed. ;-) T -- Why do conspiracy theories always come from the same people??On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: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.htmlThis 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.
Aug 13 2014
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:[...] 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!On 08/13/2014 02:50 PM, Dicebot wrote:A PR to fix this would be greatly welcomed. ;-)On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote: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.htmlThis 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.
Oct 30 2014