xref: /openbsd-src/gnu/usr.bin/perl/ext/Win32CORE/t/win32core.t (revision 6fb12b7054efc6b436584db6cef9c2f85c0d7e27)
1#!perl
2
3use Test::More;
4BEGIN {
5    if ( $ENV{PERL_CORE} ) {
6    require Config;
7	if ( $Config::Config{extensions} !~ /(?<!\S)Win32CORE(?!\S)/ ) {
8	    plan skip_all => "Win32CORE extension not built";
9	    exit();
10	}
11    }
12
13    plan tests => 6;
14};
15use_ok( "Win32CORE" );
16
17# Make sure that Win32 is not yet loaded
18ok(!defined &Win32::ExpandEnvironmentStrings,
19   "ensure other Win32::* functions aren't loaded yet");
20
21$^E = 42;
22$! = 4;
23ok(eval { Win32::GetLastError(); 1 }, 'GetLastError() works on the first call');
24my $errno = 0 + $!;
25my $sys_errno = 0 + $^E;
26SKIP: {
27    $^O eq "cygwin"
28        and skip q($^E isn't useful on cygwin), 1;
29    # [perl #42925] - Loading Win32::GetLastError() via the forwarder function
30    # should not affect the last error being retrieved
31    is($sys_errno, 42, '$^E is preserved across Win32 autoload');
32}
33is($errno, 4, '$! is preserved across Win32 autoload');
34
35# Now all Win32::* functions should be loaded
36ok(defined &Win32::ExpandEnvironmentStrings,
37   "check other Win32::* functions are loaded");
38