Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fixed function overload issue with private abs in core.time.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdavis committed Jan 17, 2012
1 parent c01fa56 commit e5c2dcf
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/core/time.d
Expand Up @@ -1744,7 +1744,6 @@ struct TickDuration
length *= value;
}

version(none)
unittest
{
immutable curr = TickDuration.currSystemTick;
Expand All @@ -1755,7 +1754,7 @@ struct TickDuration

t1 = curr;
t1 *= 2.0;
immutable tol = TickDuration(cast(long)(abs(t1.length) * double.epsilon * 2.0));
immutable tol = TickDuration(cast(long)(_abs(t1.length) * double.epsilon * 2.0));
assertApprox(t1, t2 - tol, t2 + tol);

t1 = curr;
Expand Down Expand Up @@ -1796,7 +1795,6 @@ struct TickDuration
length /= value;
}

version(none)
unittest
{
immutable curr = TickDuration.currSystemTick;
Expand All @@ -1807,7 +1805,7 @@ struct TickDuration

t2 = curr + curr;
t2 /= 2.0;
immutable tol = TickDuration(cast(long)(abs(t2.length) * double.epsilon / 2.0));
immutable tol = TickDuration(cast(long)(_abs(t2.length) * double.epsilon / 2.0));
assertApprox(t1, t2 - tol, t2 + tol);

t2 = curr + curr;
Expand Down Expand Up @@ -1844,15 +1842,14 @@ struct TickDuration
return TickDuration(cast(long)(length * value));
}

version(none)
unittest
{
foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
{
T t1 = TickDuration.currSystemTick;
T t2 = t1 + t1;
assert(t1 * 2 == t2);
immutable tol = TickDuration(cast(long)(abs(t1.length) * double.epsilon * 2.0));
immutable tol = TickDuration(cast(long)(_abs(t1.length) * double.epsilon * 2.0));
assertApprox(t1 * 2.0, t2 - tol, t2 + tol);
assert(t1 * 2.1 > t2);
}
Expand Down Expand Up @@ -1884,15 +1881,14 @@ struct TickDuration
return TickDuration(cast(long)(length / value));
}

version(none)
unittest
{
foreach(T; _TypeTuple!(TickDuration, const TickDuration, immutable TickDuration))
{
T t1 = TickDuration.currSystemTick;
T t2 = t1 + t1;
assert(t2 / 2 == t1);
immutable tol = TickDuration(cast(long)(abs(t2.length) * double.epsilon / 2.0));
immutable tol = TickDuration(cast(long)(_abs(t2.length) * double.epsilon / 2.0));
assertApprox(t2 / 2.0, t1 - tol, t1 + tol);
assert(t2 / 2.1 < t1);

Expand Down Expand Up @@ -3260,8 +3256,7 @@ version(unittest) void assertApprox()(long actual,
throw new AssertError(msg ~ ": upper: " ~ numToString(actual), __FILE__, line);
}

version(none)
version(unittest) long abs(long val)
version(unittest) long _abs(long val)
{
return val & long.max;
}

0 comments on commit e5c2dcf

Please sign in to comment.