automatically verifying code samples in phobos docs

wobbles via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 20 01:49:58 PDT 2015


On Thursday, 20 August 2015 at 06:28:44 UTC, Jacob Carlborg wrote:
> On 2015-08-20 01:41, Laeeth Isharc wrote:
>> [...]
>
> Just use a documented unit tests block:
>
> ///
> unittest
> {
>     // code goes here
> }
>
> It will be run as part of the unit tests and it will be 
> included when generating the documentation.
>
> Although I don't have a good solution for the code in dlang.org 
> that's not part of the Phobos/druntime documentation.
>
>> [...]
>
> char[] is mutable while string is not. Someone else can have a 
> reference to the same data and change it will it's typed as 
> "string", breaking the type system.

Will AutoProtocol().idup not make this work?
Make an immutable copy of whatever AutoProtocol() returns, which 
should be then immutable char[] (i.e. string)


More information about the Digitalmars-d-learn mailing list