diff options
-rw-r--r-- | src/value.cc | 10 | ||||
-rw-r--r-- | testdata/scad/functions/inf-tests.scad (renamed from testdata/scad/misc/inf-tests.scad) | 0 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/regression/echotest/builtin-tests-expected.txt | 2 | ||||
-rw-r--r-- | tests/regression/echotest/dim-all-expected.txt | 12 | ||||
-rw-r--r-- | tests/regression/echotest/inf-tests-expected.txt | 18 | ||||
-rw-r--r-- | tests/regression/echotest/parser-tests-expected.txt | 2 |
7 files changed, 26 insertions, 21 deletions
diff --git a/src/value.cc b/src/value.cc index c9440ae..47fac1e 100644 --- a/src/value.cc +++ b/src/value.cc @@ -368,11 +368,17 @@ std::string Value::toString() const // across platforms for testing purposes. { std::stringstream tmp; - tmp.precision(16); + tmp.precision(12); tmp.setf(std::ios_base::fixed); tmp << this->num; std::string tmpstr = tmp.str(); - if (tmpstr.size() > 16) tmpstr.erase(16); + size_t endpos = tmpstr.find_last_not_of('0'); + if (endpos >= 0 && tmpstr[endpos] == '.') endpos--; + tmpstr = tmpstr.substr(0, endpos+1); + size_t dotpos = tmpstr.find('.'); + if (dotpos != std::string::npos) { + if (tmpstr.size() - dotpos > 12) tmpstr.erase(dotpos + 12); + } stream << tmpstr; } #else diff --git a/testdata/scad/misc/inf-tests.scad b/testdata/scad/functions/inf-tests.scad index 87b6823..87b6823 100644 --- a/testdata/scad/misc/inf-tests.scad +++ b/testdata/scad/functions/inf-tests.scad diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e2f5699..6a3b432 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -600,8 +600,7 @@ list(APPEND ECHO_FILES ${FUNCTION_FILES} ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/builtin-tests.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/dim-all.scad ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-test.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad - ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/inf-tests.scad) + ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/string-indexing.scad) list(APPEND DUMPTEST_FILES ${MINIMAL_FILES} ${FEATURES_FILES} ${EXAMPLE_FILES}) list(APPEND DUMPTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/escape-test.scad) diff --git a/tests/regression/echotest/builtin-tests-expected.txt b/tests/regression/echotest/builtin-tests-expected.txt index 0e8d1a7..385b0dc 100644 --- a/tests/regression/echotest/builtin-tests-expected.txt +++ b/tests/regression/echotest/builtin-tests-expected.txt @@ -1 +1 @@ -ECHO: 3.14159265358979 +ECHO: 3.14159265359 diff --git a/tests/regression/echotest/dim-all-expected.txt b/tests/regression/echotest/dim-all-expected.txt index d8c3269..60f36d5 100644 --- a/tests/regression/echotest/dim-all-expected.txt +++ b/tests/regression/echotest/dim-all-expected.txt @@ -1,16 +1,16 @@ WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: linearX = 51.4495755427526 +ECHO: linearX = 51.44957554275 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: linearY = 29.1302546743484 +ECHO: linearY = 29.13025467434 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: aligned = 60.0000000000000 +ECHO: aligned = 60 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: ordinateX = -49.175424457247 +ECHO: ordinateX = -49.17542445724 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: ordinateY = 30.8697453256515 +ECHO: ordinateY = 30.86974532565 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. ECHO: radius = 60 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. ECHO: diameter = 120 WARNING: Unsupported DXF Entity `LEADER' (1) in `dim-all.dxf'. -ECHO: arc = 59.0362434679264 +ECHO: arc = 59.03624346792 diff --git a/tests/regression/echotest/inf-tests-expected.txt b/tests/regression/echotest/inf-tests-expected.txt index adac240..7ac4fe9 100644 --- a/tests/regression/echotest/inf-tests-expected.txt +++ b/tests/regression/echotest/inf-tests-expected.txt @@ -1,13 +1,13 @@ ECHO: inf ECHO: -inf -ECHO: -nan -ECHO: -nan -ECHO: -nan ECHO: nan ECHO: nan -ECHO: 90.0000000000000 -ECHO: -90.000000000000 -ECHO: 135.000000000000 +ECHO: nan +ECHO: nan +ECHO: nan +ECHO: 90 +ECHO: -90 +ECHO: 135 ECHO: inf ECHO: inf ECHO: undef @@ -17,7 +17,7 @@ ECHO: inf ECHO: -inf ECHO: inf ECHO: inf -ECHO: 1.00000000000000 -ECHO: -1.0000000000000 +ECHO: 1 +ECHO: -1 ECHO: inf -ECHO: -nan +ECHO: nan diff --git a/tests/regression/echotest/parser-tests-expected.txt b/tests/regression/echotest/parser-tests-expected.txt index fb04907..615726a 100644 --- a/tests/regression/echotest/parser-tests-expected.txt +++ b/tests/regression/echotest/parser-tests-expected.txt @@ -2,4 +2,4 @@ ECHO: 0.1 ECHO: 2 ECHO: 1100 ECHO: 0.021 -ECHO: 1.1e-13 +ECHO: 0 |