On 2011-12-29 13:59, Jakob Ovrum wrote:
On Thursday, 29 December 2011 at 12:49:55 UTC, Jacob Carlborg wrote:
For example:

import orange.test.UnitTester;

int sum (int x, int y)
{
return x * y;
}

unittest ()
{
describe("sum") in {
it("should return the sum of the two given arguments") in {
assert(sum(1, 2) == 3);
}
}
}

void main ()
{
run;
}

If a test fails the framework will print out the context, the stack
trace and a snippet from the failing test, something like this:

sum
- should return the sum of the given arguments

Failures:
1) sum should return the sum of the given arguments
# main.d:44
Stack trace:
tango.core.Exception.AssertException@main(44): Assertion failure


describe("sum") in {
it("should return the sum of the given arguments") in {
assert(sum(1, 2) == 3);
};
};

1 test, 1 failure

Operator overloading abuse, ahoy!

Yeah, I know. The "describe" and "it" functions can be changed to take the delegate as an argument instead.

--
/Jacob Carlborg

Reply via email to