File: win32core.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (37 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!perl

use Test::More;
BEGIN {
    if ( $ENV{PERL_CORE} ) {
    require Config;
	if ( $Config::Config{extensions} !~ /(?<!\S)Win32CORE(?!\S)/ ) {
	    plan skip_all => "Win32CORE extension not built";
	    exit();
	}
    }

    plan tests => 6;
};
use_ok( "Win32CORE" );

# Make sure that Win32 is not yet loaded
ok(!defined &Win32::ExpandEnvironmentStrings,
   "ensure other Win32::* functions aren't loaded yet");

$^E = 42;
$! = 4;
ok(eval { Win32::GetLastError(); 1 }, 'GetLastError() works on the first call');
my $errno = 0 + $!;
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');
}
is($errno, 4, '$! is preserved across Win32 autoload');

# Now all Win32::* functions should be loaded
ok(defined &Win32::ExpandEnvironmentStrings,
   "check other Win32::* functions are loaded");