[Issue 12269] New: Unittest within template struct scope is not executed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 26 15:23:08 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12269

           Summary: Unittest within template struct scope is not executed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: growlercab at gmail.com


--- Comment #0 from growlercab at gmail.com 2014-02-26 15:23:01 PST ---
using:

$ rdmd --main -unittest -debug utbug.d
(also tried with just dmd but same result)

---
import std.stdio;
struct S(T)
{
    T val;
    this(T v) {val=v;}
    unittest { // << UT-1
        writeln("Here 1!");
        auto s = S!int(10);

        assert(s.val == 1); // <<-- this should fail
        s=writeln("abcd"); // <<-- this should not compile

    }
}

// Uncomment to make the struct unittest run
/*
unittest { // << UT-2 
    writeln("Here 2");
    auto s = S!int(10);
    assert(s.val == 10); 
}*/
---

If UT-2 is commented out the UT-1 unit test does not get compiled and executed. 

Only occurs with template struct, non-template S works as expected.

I am running Arch Linux x86_64, dmd 2065. I have not tried to reproduce with
other configurations.

Thanks,
ed

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


More information about the Digitalmars-d-bugs mailing list