From 077332ff5cb8a41de2922a6f1be00597b30a02dd Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 25 Jun 2013 13:19:37 +0200 Subject: normalize -nan and -0 in all output modes having a stable output is not only relevant in testing, and with the main binary being used for more tests, having those normalizations takes load off the preparing scripts tests/{dumptest,echotest} diff --git a/src/value.cc b/src/value.cc index ebb825d..8320aff 100644 --- a/src/value.cc +++ b/src/value.cc @@ -182,12 +182,15 @@ public: } std::string operator()(const double &op1) const { -#ifdef OPENSCAD_TESTING - // Quick and dirty hack to work around floating point rounding differences - // across platforms for testing purposes. if (op1 != op1) { // Fix for avoiding nan vs. -nan across platforms return "nan"; } + if (op1 == 0) { + return "0"; // Don't return -0 (exactly -0 and 0 equal 0) + } +#ifdef OPENSCAD_TESTING + // Quick and dirty hack to work around floating point rounding differences + // across platforms for testing purposes. std::stringstream tmp; tmp.precision(12); tmp.setf(std::ios_base::fixed); diff --git a/tests/dumptest b/tests/dumptest index 180fa1b..0c60099 100755 --- a/tests/dumptest +++ b/tests/dumptest @@ -4,8 +4,4 @@ openscad $1 -o $2 sed 's/, timestamp = [0-9]*//' -i $2 -sed 's/-nan/nan/g' -i $2 - -sed 's/-\(0[],)]\)/\1/g' -i $2 - sed 's/-\?[0-9].[0-9]*e-[0-9]\{2,\}/0/g' -i $2 diff --git a/tests/echotest b/tests/echotest index 2ca520c..9e29878 100755 --- a/tests/echotest +++ b/tests/echotest @@ -2,8 +2,4 @@ openscad $1 -o null 2> $2 -sed 's/-nan/nan/g' -i $2 - -sed 's/-\(0[],)]\)/\1/g' -i $2 - sed 's/-\?[0-9].[0-9]*e-[0-9]\{2,\}/0/g' -i $2 -- cgit v0.10.1