[rt.cpan.org #148964] 2 failing tests when nvtype is either 'long double' or '__float128' (with patch)
[email protected] ("Sisyphus via RT") Mon, 10 Jul 2023 08:56:55 -0400
| Newsgroups | perl.libwin32 |
|---|---|
| Message-ID | <[email protected]> |
------------=_1688993815-30998-2
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Mon Jul 10 08:56:55 2023: Request 148964 was acted upon.
Transaction: Ticket created by SISYPHUS
Queue: Win32-API
Subject: 2 failing tests when nvtype is either 'long double' or
'__float128' (with patch)
Broken in: (no value)
Severity: (no value)
Owner: Nobody
Requestors: [email protected]
Status: new
Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=148964 >
In Win32-API-0.84, one test in t/00_API.t and one test in Callback/t/02_Callback.t fail if $Config{nvtype} is either 'long double' or '__float128'.
The attached patch to the 2 offending test scripts addresses this issue.
Cheers,
Rob
------------=_1688993815-30998-2
Content-Type: text/plain; charset="ascii"; name="diff.txt"
Content-Disposition: inline; filename="diff.txt"
Content-Transfer-Encoding: 7bit
RT-Attachment: 148964/2537281/1106946
--- t/00_API.t_orig 2016-01-21 17:09:22.000000000 +1100
+++ t/00_API.t 2023-07-10 22:26:08.646253600 +1000
@@ -190,7 +190,16 @@
ok(defined($function), 'API_test.dll sum_doubles function defined');
#diag("$function->{procname} \$^E=",$^E);
-ok($function->Call(2.5, 3.2) == 5.7, 'function call with double arguments');
+
+$result = $function->Call(2.5, 3.2);
+# $result holds the double precision value of the double 2.5 plus the double 3.2.
+# If nvtype is double, expect $result == sprintf("%.17g", $result) - 5.7000000000000002
+# If nvtype is long double, expect $result == sprintf("%.21g", $result) - 5.70000000000000017764
+# If nvtype is __float128, expect $result == sprintf("%.36g", $result) - 5.70000000000000017763568394002504647
+my $expected = $Config{nvtype} eq '__float128' ? 5.70000000000000017763568394002504647
+ : $Config{nvtype} eq 'double' ? 5.7
+ : 5.70000000000000017764;
+cmp_ok($result, '==', $expected, 'function call with double arguments');
# Same as above, with a pointer
$function =
--- Callback/t/02_Callback.t_orig 2016-01-21 17:09:22.000000000 +1100
+++ Callback/t/02_Callback.t 2023-07-10 22:40:31.256917000 +1000
@@ -196,7 +196,14 @@
);
$function = new Win32::API($test_dll, 'do_callback_void_d', 'K', 'D');
$result = $function->Call($callback);
-is($result, 9876.5432, "do_callback_void_d was successful");
+# $result holds the double precision value 9876.5432.
+# If nvtype is double, expect $result == sprintf("%.17g", $result) - 9876.5432000000001
+# If nvtype is long double, expect $result == sprintf("%.21g", $result) - 9876.54320000000006985
+# If nvtype is __float128, expect $result == sprintf("%.36g", $result) - 9876.54320000000006984919309616088867
+my $expected = $Config{nvtype} eq '__float128' ? 9876.54320000000006984919309616088867
+ : $Config{nvtype} eq 'double' ? 9876.5432000000001
+ : 9876.54320000000006985;
+cmp_ok($result, '==', $expected, "do_callback_void_d was successful");
$callback = Win32::API::Callback->new(
sub {
------------=_1688993815-30998-2--