Bug 14774 – core.time.numToString(double) fails its unit tests in non-release mode

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-06T09:51:00Z
Last change time
2015-07-09T04:01:20Z
Assigned to
nobody
Creator
issues.dlang
Blocks
14773

Comments

Comment #0 by issues.dlang — 2015-07-06T09:51:36Z
As I pointed out in issue# 14773, the druntime unit tests are unfortunately only run in non-release mode right now, so stuff like range violations in the tests typically aren't caught. In particular, the tests for numToString(double) in core.time fail due to range violations (it's resulting in "0.3" and not "0.33")) when built without -release, but by some quirk of the implementation, the resulting slice matches the string that it's being tested against even though they aren't actually equal. It's the tests which are currently at line# 4844: unittest { auto a = 1.337; auto aStr = numToString(a); assert(aStr[0 .. 4] == "1.33", aStr); a = 0.337; aStr = numToString(a); assert(aStr[0 .. 4] == "0.33", aStr); a = -0.337; aStr = numToString(a); assert(aStr[0 .. 5] == "-0.33", aStr); } You can also just mark the unittest block with @safe rather than editing the makefile to build druntime without -release. And if you do, the second and third tests fail.
Comment #1 by issues.dlang — 2015-07-09T04:01:20Z