From 766da84a620a7bc083553bc6f22713c1c97ae466 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 13 Nov 2024 17:56:50 +0100 Subject: [PATCH] Library: fix failed tests(1) -- Rational_test Problems in `Rational_test` were caused by `#include' reorderings regarding ''rational'' and ''intgral'' numbers. The actual root cause is the fact that `FSecs` is only a typedef, which prevents us from providing a string conversion for rational numbers without ambiguity --- src/common/instancehandle.hpp | 20 +++++++------- tests/library/rational-test.cpp | 39 ++++++++++++++-------------- tests/library/util-floordiv-test.cpp | 4 +-- wiki/thinkPad.ichthyo.mm | 31 +++++++++++++++++++--- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/src/common/instancehandle.hpp b/src/common/instancehandle.hpp index d72f4585b..b95b677a7 100644 --- a/src/common/instancehandle.hpp +++ b/src/common/instancehandle.hpp @@ -65,7 +65,7 @@ namespace lumiera { namespace { // implementation details - void + inline void throwIfError() { if (lumiera_error_peek()) @@ -78,7 +78,7 @@ namespace lumiera { * \em given instance descriptor to open an instance handle. * @throws error::Config when the registration process fails */ - LumieraInterface + inline LumieraInterface register_and_open (LumieraInterface descriptor) { if (!descriptor) return NULL; @@ -93,7 +93,7 @@ namespace lumiera { /** do a lookup within the interfaceregistry * using the name/version found within the interface * handle, to ensure it is still valid and registered */ - bool + inline bool verify_validity (LumieraInterface ifa) { REQUIRE (ifa); @@ -156,9 +156,10 @@ namespace lumiera { : util::NonCopyable { using IH = InstanceHandle; + IH& ih_; - Link (IH& ih) + Link(IH& ih) : ih_{ih} { } @@ -226,7 +227,7 @@ namespace lumiera { throwIfError(); } - ~InstanceHandle () + ~InstanceHandle() { lumiera_interface_close (&instance_->interface_header_); if (desc_) @@ -239,14 +240,14 @@ namespace lumiera { * @note we don't provide `operator*` */ FA* - operator-> () const + operator->() const { return facadeLink_.operator ->(); } /** directly access the instance via the CL interface */ I& - get () const + get() const { ENSURE(instance_); return *instance_; @@ -270,11 +271,10 @@ namespace lumiera { isValid() const { return instance_ - && verify_validity (&instance_->interface_header_); + and verify_validity (&instance_->interface_header_); } }; } // namespace lumiera - -#endif +#endif /*LUMIERA_INSTANCEHANDLE_H*/ diff --git a/tests/library/rational-test.cpp b/tests/library/rational-test.cpp index 4389e3ea4..f3d80a5c3 100644 --- a/tests/library/rational-test.cpp +++ b/tests/library/rational-test.cpp @@ -30,6 +30,7 @@ #include "lib/test/run.hpp" #include "lib/integral.hpp" #include "lib/format-cout.hpp" +#include "lib/test/test-helper.hpp" #include "lib/rational.hpp" @@ -87,9 +88,9 @@ namespace test { CHECK (2_r/3 /(3_r/4)== 8_r/9); CHECK (2_r/3 / 3 /4 == 1_r/18); // usual precedence and brace rules apply, yielding 2/36 here - CHECK (util::toString(23_r/55) == "23/55sec"); //////////////////////////TICKET #1259 and #1261 : FSecs should really be a distinct (wrapper) type, - //////////////////////////TICKET #1259 and #1261 : ...then this custom conversion with the suffix "sec" would not kick in here - CHECK (util::toString(24_r/56) == "3/7sec" ); // rational numbers are normalised and reduced immediately + CHECK (util::toString(23_r/55) == "23/55sec"_expect); ///////////////////TICKET #1259 and #1261 : FSecs should really be a distinct (wrapper) type, + ///////////////////TICKET #1259 and #1261 : ...then this custom conversion with the suffix "sec" would not kick in here + CHECK (util::toString(24_r/56) == "3/7sec"_expect ); // rational numbers are normalised and reduced immediately CHECK (Rat(10,3).numerator() == int64_t(10)); CHECK (Rat(10,3).denominator() == int64_t(3)); @@ -118,32 +119,32 @@ namespace test { CHECK (MAXI > 0); // so this one still works CHECK (MAXI+1 < 0); // but one more and we get a wrap-around CHECK (MAXI+1 < -MAXI); - CHECK (util::toString(MAXI) == "9223372036854775807sec"); /////////TICKET #1259 should be "9223372036854775807/1 -- get rid of the "sec" suffix - CHECK (util::toString(MAXI+1) == "-9223372036854775808sec"); /////////TICKET #1259 should be "-9223372036854775808/1" - CHECK (util::toString(-MAXI) == "-9223372036854775807sec"); /////////TICKET #1259 should be "-9223372036854775807/1" + CHECK (util::toString(MAXI) == "9223372036854775807sec"_expect); /////////TICKET #1259 should be "9223372036854775807/1 -- get rid of the "sec" suffix + CHECK (util::toString(MAXI+1) == "-9223372036854775808sec"_expect); /////////TICKET #1259 should be "-9223372036854775808/1" + CHECK (util::toString(-MAXI) == "-9223372036854775807sec"_expect); /////////TICKET #1259 should be "-9223372036854775807/1" CHECK (MINI > 0); // smallest representable number above zero CHECK (1-MINI < 1); CHECK (0 < 1-MINI); // can be used below 1 just fine CHECK (0 > 1+MINI); // but above we get a wrap-around in normalised numerator - CHECK (util::toString(MINI) == "1/9223372036854775807sec"); - CHECK (util::toString(-MINI) == "-1/9223372036854775807sec"); - CHECK (util::toString(1-MINI) == "9223372036854775806/9223372036854775807sec"); - CHECK (util::toString(1+MINI) == "-9223372036854775808/9223372036854775807sec"); + CHECK (util::toString(MINI) == "1/9223372036854775807sec"_expect); + CHECK (util::toString(-MINI) == "-1/9223372036854775807sec"_expect); + CHECK (util::toString(1-MINI) == "9223372036854775806/9223372036854775807sec"_expect); + CHECK (util::toString(1+MINI) == "-9223372036854775808/9223372036854775807sec"_expect); CHECK ((MAXI-1)/MAXI == 1-MINI); CHECK (MAXI/(MAXI-1) > 1); // as workaround we have to use a slightly larger ULP CHECK (MAXI/(MAXI-1) - 1 > MINI); // ...this slightly larger one works without wrap-around CHECK (1 - MAXI/(MAXI-1) < -MINI); - CHECK (util::toString(MAXI/(MAXI-1)) == "9223372036854775807/9223372036854775806sec"); - CHECK (util::toString(MAXI/(MAXI-1) - 1) == "1/9223372036854775806sec"); - CHECK (util::toString(1 - MAXI/(MAXI-1)) == "-1/9223372036854775806sec"); + CHECK (util::toString(MAXI/(MAXI-1)) == "9223372036854775807/9223372036854775806sec"_expect); + CHECK (util::toString(MAXI/(MAXI-1) - 1) == "1/9223372036854775806sec"_expect); + CHECK (util::toString(1 - MAXI/(MAXI-1)) == "-1/9223372036854775806sec"_expect); // Now entering absolute danger territory.... const Rat MIMI = -MAXI-1; // this is the most extreme negative representable value CHECK (MIMI < 0); - CHECK (util::toString(MIMI) == "-9223372036854775808sec"); /////////TICKET #1259 should be "-9223372036854775808/1" - CHECK (util::toString(1/MIMI) == "-1/-9223372036854775808sec"); + CHECK (util::toString(MIMI) == "-9223372036854775808sec"_expect); /////////TICKET #1259 should be "-9223372036854775808/1" + CHECK (util::toString(1/MIMI) == "-1/-9223372036854775808sec"_expect); try { -1-1/MIMI; // ...but it can't be used for any calculation without blowing up @@ -354,10 +355,10 @@ namespace test { CHECK (approx (sleazy+7) == 14); CHECK (approx (sleazy+9_r/5) == 8.80000019f); - CHECK (util::toString (poison) == "9223372036854775719/1317624576693539401sec"); - CHECK (util::toString (poison+1) =="-7905747460161236496/1317624576693539401sec"); - CHECK (util::toString (sleazy) == "117440511/16777216sec"); - CHECK (util::toString (sleazy+1) == "134217727/16777216sec"); + CHECK (util::toString (poison) == "9223372036854775719/1317624576693539401sec"_expect); + CHECK (util::toString (poison+1) =="-7905747460161236496/1317624576693539401sec"_expect); + CHECK (util::toString (sleazy) == "117440511/16777216sec"_expect); + CHECK (util::toString (sleazy+1) == "134217727/16777216sec"_expect); // also works towards larger denominator, or with negative numbers... CHECK (reQuant (1/poison, MAX) == 1317624576693539413_r/9223372036854775807); diff --git a/tests/library/util-floordiv-test.cpp b/tests/library/util-floordiv-test.cpp index fd720af20..d3a4d57dc 100644 --- a/tests/library/util-floordiv-test.cpp +++ b/tests/library/util-floordiv-test.cpp @@ -59,8 +59,8 @@ namespace test { VecI data; for (uint i=0; i - + @@ -57521,9 +57521,35 @@ 0000000515: CHECK: rational-test.cpp:90: thread_1: demonstrate_basics: (util::toString(23_r/55) == "23/55sec")

+
+ + + + + + +

+ ...hatte vor einiger Zeit aufgeräumt und einen eigenen #include "lib/integral.hpp" geschaffen. Dadurch ist downstream der #include für time-value.hpp rausgefallen, und damit fehlte die String-conversion für Rationals +

+
+ + + + + + +

+ ...dazu nochmal über die ganze Problematik nachgedacht und entsprechende Kommentare in #1258 und #1261 hinterlassen +

+ + +
+ +
+
@@ -57538,8 +57564,7 @@ 0000000598: UNIMPLEMENTED: scheduler-commutator.hpp:204: thread_1: findWork: how to trigger a Scheduler-Emergency from here

- -
+