[Issue 5038] New: Change class 'invariant' syntax to emulate 'unittest'

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 10 15:10:26 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5038

           Summary: Change class 'invariant' syntax to emulate 'unittest'
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: ah08010-d at yahoo.com


--- Comment #0 from Austin Hastings <ah08010-d at yahoo.com> 2010-10-10 15:09:58 PDT ---
Presently a class invariant is required to be a single function:

class C {
    int height;
    int width;

    invariant() {
        assert( height < 10 );
        assert( width < 11 );
    }
}

For large and/or complex classes, it would improve locality if the invariant
could be specified piecemeal, in much the same was that unittest blocks are
stitched together into a whole:

class C {
    int height;

    invariant {
        assert( height < 10 );
    }

    int width;

    invariant {
        assert( width < 11 );
    }
}

The parentheses after invariant seem useless, too - also very much like
unittest.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list