There is a bug for '-unittest'?

FrankLike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 26 06:38:17 PDT 2014


Hello,every one:
There is a unit test for a.d,it will be pass,do you think it's 
right?
or it's my error?

/////// the file name is a.d
   class Math
{
     /// add function
     static int add(int x, int y) { return x + y; }

     ///
     unittest
     {
        // assert(add(2, 2) == 5);
         assert(add(-2,0) == 0);
     }
}

class Sum {
   int add(int x, int y) { return x + y; }

   unittest
   {
     Sum sum = new Sum;
     //assert(sum.add(-2,0) == -2);
      assert(sum.add(-2,0) == 2);
   }
}

void main()
{
}
//// build.bat
dmd -unittest a.d
pause

-------------------------end----------------------------

Thank you.


More information about the Digitalmars-d-learn mailing list