Skip to content

Commit

Permalink
abs unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Mar 5, 2015
1 parent 83f7a87 commit ecfc777
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions std/math.d
Expand Up @@ -525,6 +525,23 @@ auto abs(Num)(Num y) @safe pure nothrow @nogc
assert(abs(-1L+1i) == sqrt(2.0L));
}

@safe pure nothrow @nogc unittest
{
import std.typetuple;
foreach (T; TypeTuple!(float, double, real))
{
T f = 3;
assert(abs(f) == f);
assert(abs(-f) == f);
}
foreach (T; TypeTuple!(cfloat, cdouble, creal))
{
T f = -12+3i;
assert(abs(f) == hypot(f.re, f.im));
assert(abs(-f) == hypot(f.re, f.im));
}
}

/***********************************
* Complex conjugate
*
Expand Down

0 comments on commit ecfc777

Please sign in to comment.