cygwin doesn't implement $^E (except as a read of $!)
authorTony Cook <tony@develop-help.com>
Wed, 19 Feb 2014 04:01:06 +0000 (15:01 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 19 Feb 2014 04:40:33 +0000 (15:40 +1100)
On Cygwin, reading $^E actually reads $!, as it does on other non-
VMS/Win32/OS/2 platforms.  Setting it does nothing.

ext/Win32CORE/t/win32core.t

index 5eb0bc4..64f2e95 100644 (file)
@@ -10,17 +10,25 @@ BEGIN {
        }
     }
 
-        plan tests => 4;
+    plan tests => 5;
 };
 use_ok( "Win32CORE" );
 
 # Make sure that Win32 is not yet loaded
-ok(!defined &Win32::ExpandEnvironmentStrings);
+ok(!defined &Win32::ExpandEnvironmentStrings,
+   "ensure other Win32::* functions aren't loaded yet");
 
-# [perl #42925] - Loading Win32::GetLastError() via the forwarder function
-# should not affect the last error being retrieved
 $^E = 42;
-is(Win32::GetLastError(), $^O eq 'cygwin' ? 0 : 42, 'GetLastError() works on the first call');
+ok(eval { Win32::GetLastError(); 1 }, 'GetLastError() works on the first call');
+my $sys_errno = 0 + $^E;
+SKIP: {
+    $^O eq "cygwin"
+        and skip q($^E isn't useful on cygwin), 1;
+    # [perl #42925] - Loading Win32::GetLastError() via the forwarder function
+    # should not affect the last error being retrieved
+    is($sys_errno, 42, '$^E is preserved across Win32 autoload');
+}
 
 # Now all Win32::* functions should be loaded
-ok(defined &Win32::ExpandEnvironmentStrings);
+ok(defined &Win32::ExpandEnvironmentStrings,
+   "check other Win32::* functions are loaded");