Subject: | [Win32] t/05_vcos.t failure |
Hi,
On Windows, the string 'nan' is not a reliable way of creating a NaN - with older perl versions, at least.
It probably varies on Windows depending upon the actual compiler that was used to build perl and I'm hopeful that it's not an issue at all for perl-5.22.0 and later (though I haven't verified that).
On my 32-bit perls 5.12.0, 5.14.0, 5.16.0 and 5.18.0 the expression "pdl([1, 'nan', -1])" creates a piddle that is [1, 0, -1].
Hence test 3 of t/05_vcos.t fails on those perls.
Here's a patch to t/05_vcos.t that fixes this Windows issue for me by creating the NaN as an "infinity minus infinity":
#################################
--- 05_vcos.t_orig 2016-06-05 12:31:40 +1000
+++ 05_vcos.t 2016-06-05 12:53:10 +1000
@@ -34,8 +34,9 @@
##-- 3: vcos: nullvec: a
my $a0 = $a->pdl;
+my $nan = $^O =~ /MSWin32/i ? ((99**99)**99) - ((99**99)**99) : 'nan';
(my $tmp=$a0->slice(",1")) .= 0;
-pdlapprox("vv_vcos:nullvec:a:nan", $a0->vv_vcos($b), pdl([1,'nan',-1]), 1e-4);
+pdlapprox("vv_vcos:nullvec:a:nan", $a0->vv_vcos($b), pdl([1,$nan,-1]), 1e-4);
##-- 4: vcos: nullvec: b
my $b0 = $b->zeroes;
#################################
Note that it's a Windows-specific patch, and leaves the script essentially unchanged for non-Windows systems.
It allows all test pass on all of my Windows perls (up to and including 5.24.0).
BTW, it's important that the infinity be created as (99**99)**99. On a few of my Windows builds, if the brackets are left out then 99**99**99 evaluates to 0.
(That happens on and only on all of my perls that were built using a mingw64 port of 64-bit gcc-4.7.0. Thankfully I left that compiler behind when 5.20 was released.)
I guess we could alternatively create the NaN using 'pack', but that formulation would need to cater for differing $Config{nvtype} values.
Cheers,
Rob