Introducing mach.d, the github repo where I put whatever modules I happen to write
pineapple via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed May 25 15:29:38 PDT 2016
On Wednesday, 25 May 2016 at 22:19:28 UTC, Seb wrote:
> I know that writing your own library is fun, but something that
> I see quite often when looking at e.g.
Yep, I saw a couple of those before I got started on mine. For
some of us it's a sense of ownership, I think. It feels good to
be building projects on top of code I wrote myself.
> mach.error.unit
> -> http://code.dlang.org/packages/unit-threaded
Actually, my module isn't a unittest framework - though I intend
to take a shot at one of those, too, at some point. Instead it's
a substitute for "assert" everywhere that results in more
descriptive errors in case of failure.
For example, this is one way to indicate that some group of
not-asserts are testing the same general subject:
tests("Some feature", {
...
});
And when you do something like this -
testeq("not", "equal");
You get an error message like this -
mach.error.unit.TestFailureError at E:\Dropbox\Projects\d\mach\error\unit.d(215): Values must be equal not and equal
Which you can further customize -
testeq("This is an example and should always fail.", "not",
"equal");
Resulting in this -
mach.error.unit.TestFailureError at E:\Dropbox\Projects\d\mach\error\unit.d(215): This is an example and should always fail. not and equal
And you can also do some cool stuff like this -
fail(
"Catch a TestFailureError",
(caught) => (cast(TestFailureError) caught !is null),
{testeq("not", "equal");}
);
> mach.math.round
> -> sounds like a feature that could be useful for everyone. How
> about making a PR to Phobos?
>
> ...
I will do that
More information about the Digitalmars-d-announce
mailing list