Proposal: Database Engine for D

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 4 06:36:56 PST 2016


On 01/04/2016 08:09 AM, John Colvin wrote:
> On Monday, 4 January 2016 at 12:28:47 UTC, Russel Winder wrote:
>> I must now try creating a D version of the pytest.mark.parametrize
>> decorator – unless someone already has and I have just missed it.
>
> I quick look at pytest.mark.parametrize suggests it could be implemented
> with UDAs and a test-runner that finds all declarations a module
> (recursively) and does all the relevant logic (e.g. that's got more than
> one instance of parametrize, so do some sort of cartesian product of the
> inputs) and actually runs the test.
>
> The main thing that python has here over D is that D's UDAs can't
> directly modify the function they're attached to, but I don't think
> that's necessary for parametrize.
>
> Interestingly, functions can query their own attributes:
>
> @(3) auto attr()
> {
>      return __traits(getAttributes, attr)[0];
> }
>
> unittest
> {
>      assert(attr() == 3);
> }
>
> not sure when I'd use that though...

For computed attributes in template functions. -- Andrei



More information about the Digitalmars-d mailing list