diff options
author | 2014-03-24 14:58:42 +0000 | |
---|---|---|
committer | 2014-03-24 14:58:42 +0000 | |
commit | 91f110e064cd7c194e59e019b83bb7496c1c84d4 (patch) | |
tree | 3e8e577405dba7e94b43cbf21c22f21aaa5ab949 /gnu/usr.bin/perl/cpan/Win32/t | |
parent | do not call purge_task every 10 secs, it is only needed once at startup and (diff) | |
download | wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.tar.xz wireguard-openbsd-91f110e064cd7c194e59e019b83bb7496c1c84d4.zip |
Import perl-5.18.2
OK espie@ sthen@ deraadt@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Win32/t')
-rw-r--r-- | gnu/usr.bin/perl/cpan/Win32/t/CodePage.t | 27 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/CreateFile.t | 62 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/ExpandEnvironmentStrings.t | 14 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetCurrentThreadId.t | 76 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetFileVersion.t | 36 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetFolderPath.t | 16 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetFullPathName.t | 68 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetLongPathName.t | 106 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetOSName.t | 5 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetOSVersion.t | 22 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t | 40 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/GuidGen.t | 30 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/Names.t | 113 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/Win32/t/Unicode.t | 175 |
14 files changed, 412 insertions, 378 deletions
diff --git a/gnu/usr.bin/perl/cpan/Win32/t/CodePage.t b/gnu/usr.bin/perl/cpan/Win32/t/CodePage.t new file mode 100644 index 00000000000..75741cc9749 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/Win32/t/CodePage.t @@ -0,0 +1,27 @@ +use strict; +use Test; +use Win32; + +plan tests => 8; + +my $ansicp = Win32::GetACP(); +ok($ansicp > 0 && $ansicp <= 65001); + +my $inputcp = Win32::GetConsoleCP(); +ok($inputcp > 0 && $inputcp <= 65001); + +my $outputcp = Win32::GetConsoleOutputCP(); +ok($outputcp > 0 && $outputcp <= 65001); + +my $oemcp = Win32::GetOEMCP(); +ok($oemcp > 0 && $oemcp <= 65001); + +ok(Win32::SetConsoleCP($ansicp)); +ok(Win32::GetConsoleCP() == $ansicp); + +ok(Win32::SetConsoleOutputCP($ansicp)); +ok(Win32::GetConsoleOutputCP() == $ansicp); + +# Reset things when we're done. +Win32::SetConsoleCP($inputcp); +Win32::SetConsoleOutputCP($outputcp); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/CreateFile.t b/gnu/usr.bin/perl/cpan/Win32/t/CreateFile.t index 63ce31694cf..ee1bf46daf9 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/CreateFile.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/CreateFile.t @@ -1,31 +1,31 @@ -use strict;
-use Test;
-use Win32;
-
-my $path = "testing-$$";
-rmdir($path) if -d $path;
-unlink($path) if -f $path;
-
-plan tests => 15;
-
-ok(!-d $path);
-ok(!-f $path);
-
-ok(Win32::CreateDirectory($path));
-ok(-d $path);
-
-ok(!Win32::CreateDirectory($path));
-ok(!Win32::CreateFile($path));
-
-ok(rmdir($path));
-ok(!-d $path);
-
-ok(Win32::CreateFile($path));
-ok(-f $path);
-ok(-s $path, 0);
-
-ok(!Win32::CreateDirectory($path));
-ok(!Win32::CreateFile($path));
-
-ok(unlink($path));
-ok(!-f $path);
+use strict; +use Test; +use Win32; + +my $path = "testing-$$"; +rmdir($path) if -d $path; +unlink($path) if -f $path; + +plan tests => 15; + +ok(!-d $path); +ok(!-f $path); + +ok(Win32::CreateDirectory($path)); +ok(-d $path); + +ok(!Win32::CreateDirectory($path)); +ok(!Win32::CreateFile($path)); + +ok(rmdir($path)); +ok(!-d $path); + +ok(Win32::CreateFile($path)); +ok(-f $path); +ok(-s $path, 0); + +ok(!Win32::CreateDirectory($path)); +ok(!Win32::CreateFile($path)); + +ok(unlink($path)); +ok(!-f $path); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/ExpandEnvironmentStrings.t b/gnu/usr.bin/perl/cpan/Win32/t/ExpandEnvironmentStrings.t index 853be4aa0ed..b57b47cddd7 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/ExpandEnvironmentStrings.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/ExpandEnvironmentStrings.t @@ -1,7 +1,7 @@ -use strict;
-use Test;
-use Win32;
-
-plan tests => 1;
-
-ok(Win32::ExpandEnvironmentStrings("%WINDIR%"), $ENV{WINDIR});
+use strict; +use Test; +use Win32; + +plan tests => 1; + +ok(Win32::ExpandEnvironmentStrings("%WINDIR%"), $ENV{WINDIR}); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetCurrentThreadId.t b/gnu/usr.bin/perl/cpan/Win32/t/GetCurrentThreadId.t index 6117e3ef663..ce98f3e5626 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetCurrentThreadId.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetCurrentThreadId.t @@ -1,38 +1,38 @@ -use strict;
-use Config qw(%Config);
-use Test;
-use Win32;
-
-my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/;
-
-my $tests = $fork_emulation ? 4 : 2;
-plan tests => $tests;
-
-my $pid = $$+0; # make sure we don't copy any magic to $pid
-
-if ($^O eq "cygwin") {
- skip(!defined &Cygwin::pid_to_winpid,
- Cygwin::pid_to_winpid($pid),
- Win32::GetCurrentProcessId());
-}
-else {
- ok($pid, Win32::GetCurrentProcessId());
-}
-
-if ($fork_emulation) {
- # This test relies on the implementation detail that the fork() emulation
- # uses the negative value of the thread id as a pseudo process id.
- if (my $child = fork) {
- waitpid($child, 0);
- exit 0;
- }
- ok(-$$, Win32::GetCurrentThreadId());
-
- # GetCurrentProcessId() should still return the real PID
- ok($pid, Win32::GetCurrentProcessId());
- ok($$ != Win32::GetCurrentProcessId());
-}
-else {
- # here we just want to see something.
- ok(Win32::GetCurrentThreadId() > 0);
-}
+use strict; +use Config qw(%Config); +use Test; +use Win32; + +my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/; + +my $tests = $fork_emulation ? 4 : 2; +plan tests => $tests; + +my $pid = $$+0; # make sure we don't copy any magic to $pid + +if ($^O eq "cygwin") { + skip(!defined &Cygwin::pid_to_winpid, + Cygwin::pid_to_winpid($pid), + Win32::GetCurrentProcessId()); +} +else { + ok($pid, Win32::GetCurrentProcessId()); +} + +if ($fork_emulation) { + # This test relies on the implementation detail that the fork() emulation + # uses the negative value of the thread id as a pseudo process id. + if (my $child = fork) { + waitpid($child, 0); + exit 0; + } + ok(-$$, Win32::GetCurrentThreadId()); + + # GetCurrentProcessId() should still return the real PID + ok($pid, Win32::GetCurrentProcessId()); + ok($$ != Win32::GetCurrentProcessId()); +} +else { + # here we just want to see something. + ok(Win32::GetCurrentThreadId() > 0); +} diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetFileVersion.t b/gnu/usr.bin/perl/cpan/Win32/t/GetFileVersion.t index 6e42fb779f7..b9e51f821d9 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetFileVersion.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetFileVersion.t @@ -1,18 +1,18 @@ -use strict;
-use Test;
-use Win32;
-
-unless (defined &Win32::BuildNumber) {
- print "1..0 # Skip: Only ActivePerl seems to set the perl.exe fileversion\n";
- exit;
-}
-
-plan tests => 2;
-
-my @version = Win32::GetFileVersion($^X);
-my $version = $version[0] + $version[1] / 1000 + $version[2] / 1000000;
-
-# numify $] because it is a version object in 5.10 which will stringify with trailing 0s
-ok($version, 0+$]);
-
-ok($version[3], int(Win32::BuildNumber()));
+use strict; +use Test; +use Win32; + +unless (defined &Win32::BuildNumber) { + print "1..0 # Skip: Only ActivePerl seems to set the perl.exe fileversion\n"; + exit; +} + +plan tests => 2; + +my @version = Win32::GetFileVersion($^X); +my $version = $version[0] + $version[1] / 1000 + $version[2] / 1000000; + +# numify $] because it is a version object in 5.10 which will stringify with trailing 0s +ok($version, 0+$]); + +ok($version[3], int(Win32::BuildNumber())); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetFolderPath.t b/gnu/usr.bin/perl/cpan/Win32/t/GetFolderPath.t index ad8df99ecc9..c010c25aa88 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetFolderPath.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetFolderPath.t @@ -1,8 +1,8 @@ -use strict;
-use Test;
-use Win32;
-
-plan tests => 1;
-
-# "windir" exists back to Win9X; "SystemRoot" only exists on WinNT and later.
-ok(Win32::GetFolderPath(Win32::CSIDL_WINDOWS), $ENV{WINDIR});
+use strict; +use Test; +use Win32; + +plan tests => 1; + +# "windir" exists back to Win9X; "SystemRoot" only exists on WinNT and later. +ok(Win32::GetFolderPath(Win32::CSIDL_WINDOWS), $ENV{WINDIR}); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetFullPathName.t b/gnu/usr.bin/perl/cpan/Win32/t/GetFullPathName.t index 15542e5e658..ec716d15d24 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetFullPathName.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetFullPathName.t @@ -1,34 +1,34 @@ -use strict;
-use Test;
-use Win32;
-
-plan tests => 16;
-
-my $cwd = Win32::GetCwd;
-my @cwd = split/\\/, $cwd;
-my $file = pop @cwd;
-my $dir = join('\\', @cwd);
-
-ok(scalar Win32::GetFullPathName('.'), $cwd);
-ok((Win32::GetFullPathName('.'))[0], "$dir\\");
-ok((Win32::GetFullPathName('.'))[1], $file);
-
-ok((Win32::GetFullPathName('./'))[0], "$cwd\\");
-ok((Win32::GetFullPathName('.\\'))[0], "$cwd\\");
-ok((Win32::GetFullPathName('./'))[1], "");
-
-ok(scalar Win32::GetFullPathName($cwd), $cwd);
-ok((Win32::GetFullPathName($cwd))[0], "$dir\\");
-ok((Win32::GetFullPathName($cwd))[1], $file);
-
-ok(scalar Win32::GetFullPathName(substr($cwd,2)), $cwd);
-ok((Win32::GetFullPathName(substr($cwd,2)))[0], "$dir\\");
-ok((Win32::GetFullPathName(substr($cwd,2)))[1], $file);
-
-ok(scalar Win32::GetFullPathName('/Foo Bar/'), substr($cwd,0,2)."\\Foo Bar\\");
-
-chdir($dir);
-ok(scalar Win32::GetFullPathName('.'), $dir);
-
-ok((Win32::GetFullPathName($file))[0], "$dir\\");
-ok((Win32::GetFullPathName($file))[1], $file);
+use strict; +use Test; +use Win32; + +plan tests => 16; + +my $cwd = Win32::GetCwd; +my @cwd = split/\\/, $cwd; +my $file = pop @cwd; +my $dir = join('\\', @cwd); + +ok(scalar Win32::GetFullPathName('.'), $cwd); +ok((Win32::GetFullPathName('.'))[0], "$dir\\"); +ok((Win32::GetFullPathName('.'))[1], $file); + +ok((Win32::GetFullPathName('./'))[0], "$cwd\\"); +ok((Win32::GetFullPathName('.\\'))[0], "$cwd\\"); +ok((Win32::GetFullPathName('./'))[1], ""); + +ok(scalar Win32::GetFullPathName($cwd), $cwd); +ok((Win32::GetFullPathName($cwd))[0], "$dir\\"); +ok((Win32::GetFullPathName($cwd))[1], $file); + +ok(scalar Win32::GetFullPathName(substr($cwd,2)), $cwd); +ok((Win32::GetFullPathName(substr($cwd,2)))[0], "$dir\\"); +ok((Win32::GetFullPathName(substr($cwd,2)))[1], $file); + +ok(scalar Win32::GetFullPathName('/Foo Bar/'), substr($cwd,0,2)."\\Foo Bar\\"); + +chdir($dir); +ok(scalar Win32::GetFullPathName('.'), $dir); + +ok((Win32::GetFullPathName($file))[0], "$dir\\"); +ok((Win32::GetFullPathName($file))[1], $file); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetLongPathName.t b/gnu/usr.bin/perl/cpan/Win32/t/GetLongPathName.t index b7da71991ce..5019a2ba258 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetLongPathName.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetLongPathName.t @@ -1,53 +1,53 @@ -use strict;
-use Test;
-use Win32;
-
-my @paths = qw(
- /
- //
- .
- ..
- c:
- c:/
- c:./
- c:/.
- c:/..
- c:./..
- //./
- //.
- //..
- //./..
-);
-push @paths, map { my $x = $_; $x =~ s,/,\\,g; $x } @paths;
-push @paths, qw(
- ../\
- c:.\\../\
- c:/\..//
- c://.\/./\
- \\.\\../\
- //\..//
- //.\/./\
-);
-
-my $drive = $ENV{SYSTEMDRIVE};
-if ($drive) {
- for (@paths) {
- s/^c:/$drive/;
- }
-}
-my %expect;
-@expect{@paths} = map { my $x = $_;
- $x =~ s,(.[/\\])[/\\]+,$1,g;
- $x =~ s,^(\w):,\U$1:,;
- $x } @paths;
-
-plan tests => scalar(@paths);
-
-my $i = 1;
-for (@paths) {
- my $got = Win32::GetLongPathName($_);
- print "# '$_' => expect '$expect{$_}' => got '$got'\n";
- print "not " unless $expect{$_} eq $got;
- print "ok $i\n";
- ++$i;
-}
+use strict; +use Test; +use Win32; + +my @paths = qw( + / + // + . + .. + c: + c:/ + c:./ + c:/. + c:/.. + c:./.. + //./ + //. + //.. + //./.. +); +push @paths, map { my $x = $_; $x =~ s,/,\\,g; $x } @paths; +push @paths, qw( + ../\ + c:.\\../\ + c:/\..// + c://.\/./\ + \\.\\../\ + //\..// + //.\/./\ +); + +my $drive = $ENV{SYSTEMDRIVE}; +if ($drive) { + for (@paths) { + s/^c:/$drive/; + } +} +my %expect; +@expect{@paths} = map { my $x = $_; + $x =~ s,(.[/\\])[/\\]+,$1,g; + $x =~ s,^(\w):,\U$1:,; + $x } @paths; + +plan tests => scalar(@paths); + +my $i = 1; +for (@paths) { + my $got = Win32::GetLongPathName($_); + print "# '$_' => expect '$expect{$_}' => got '$got'\n"; + print "not " unless $expect{$_} eq $got; + print "ok $i\n"; + ++$i; +} diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetOSName.t b/gnu/usr.bin/perl/cpan/Win32/t/GetOSName.t index 32a43df70e9..07fed88f400 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetOSName.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetOSName.t @@ -99,8 +99,9 @@ my @dual_tests = ( ["7 [Enterprise]", "7", 2, 6, 1, 0x04 ],
["7 [Ultimate]", "7", 2, 6, 1, 0x01 ],
-
+["8", "8", 2, 6, 2 ],
["2008 [R2]", "2008", 2, 6, 1, 0x00, 2, 89 ],
+["2012", "2012", 2, 6, 2, 0x00, 2, 89 ],
["[Small Business Server] 2008 R2", "2008", 2, 6, 1, 0x09, 2, 89 ],
);
@@ -127,7 +128,7 @@ sub check { # and 2003/2008 start with "Windows Server"
unless ($pretty eq "Win32s") {
my $prefix = "Windows";
- $prefix .= " Server" if $pretty =~ /^200[38]/;
+ $prefix .= " Server" if $pretty =~ /^20(03|08|12)/;
$pretty = "$prefix $pretty";
}
diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetOSVersion.t b/gnu/usr.bin/perl/cpan/Win32/t/GetOSVersion.t index 0038ef70e69..cb3f36490ba 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetOSVersion.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetOSVersion.t @@ -1,11 +1,11 @@ -use strict;
-use Test;
-use Win32;
-
-plan tests => 1;
-
-my $scalar = Win32::GetOSVersion();
-my @array = Win32::GetOSVersion();
-
-print "not " unless $scalar == $array[4];
-print "ok 1\n";
+use strict; +use Test; +use Win32; + +plan tests => 1; + +my $scalar = Win32::GetOSVersion(); +my @array = Win32::GetOSVersion(); + +print "not " unless $scalar == $array[4]; +print "ok 1\n"; diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t b/gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t index 34adf965720..455385418c5 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GetShortPathName.t @@ -1,20 +1,20 @@ -use strict;
-use Test;
-use Win32;
-
-my $path = "Long Path $$";
-unlink($path);
-END { unlink $path }
-
-plan tests => 5;
-
-Win32::CreateFile($path);
-ok(-f $path);
-
-my $short = Win32::GetShortPathName($path);
-ok($short, qr/^\S{1,8}(\.\S{1,3})?$/);
-ok(-f $short);
-
-unlink($path);
-ok(!-f $path);
-ok(!defined Win32::GetShortPathName($path));
+use strict; +use Test; +use Win32; + +my $path = "Long Path $$"; +unlink($path); +END { unlink $path } + +plan tests => 5; + +Win32::CreateFile($path); +ok(-f $path); + +my $short = Win32::GetShortPathName($path); +ok($short, qr/^\S{1,8}(\.\S{1,3})?$/); +ok(-f $short); + +unlink($path); +ok(!-f $path); +ok(!defined Win32::GetShortPathName($path)); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/GuidGen.t b/gnu/usr.bin/perl/cpan/Win32/t/GuidGen.t index 9ee8ede9340..7011e2f1492 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/GuidGen.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/GuidGen.t @@ -1,15 +1,15 @@ -use strict;
-use Test;
-use Win32;
-
-plan tests => 3;
-
-my $guid1 = Win32::GuidGen();
-my $guid2 = Win32::GuidGen();
-
-# {FB9586CD-273B-43BE-A20C-485A6BD4FCD6}
-ok($guid1, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/);
-ok($guid2, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/);
-
-# Every GUID is unique
-ok($guid1 ne $guid2);
+use strict; +use Test; +use Win32; + +plan tests => 3; + +my $guid1 = Win32::GuidGen(); +my $guid2 = Win32::GuidGen(); + +# {FB9586CD-273B-43BE-A20C-485A6BD4FCD6} +ok($guid1, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); +ok($guid2, qr/^{\w{8}(-\w{4}){3}-\w{12}}$/); + +# Every GUID is unique +ok($guid1 ne $guid2); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/Names.t b/gnu/usr.bin/perl/cpan/Win32/t/Names.t index ecab79f78be..e28e4a46af3 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/Names.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/Names.t @@ -1,56 +1,57 @@ -use strict;
-BEGIN {
- eval "use Test::More";
- return unless $@;
- print "1..0 # Skip: Test requires Test::More module\n";
- exit 0;
-}
-use Win32;
-
-my $tests = 14;
-$tests += 2 if Win32::IsWinNT();
-
-plan tests => $tests;
-
-# test Win32::DomainName()
-if (Win32::IsWinNT()) {
- my $domain = eval { Win32::DomainName() };
- SKIP: {
- skip('The Workstation service has not been started', 2) if (Win32::GetLastError() == 2138);
- is( $@, '', "Win32::DomainName()" );
- like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', " - checking returned domain" );
- }
-}
-
-# test Win32::GetArchName()
-my $archname = eval { Win32::GetArchName() };
-is( $@, '', "Win32::GetArchName()" );
-cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" );
-
-# test Win32::GetChipName()
-my $chipname = eval { Win32::GetChipName() };
-is( $@, '', "Win32::GetChipName()" );
-cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" );
-
-# test Win32::GetOSName()
-# - scalar context
-my $osname = eval { Win32::GetOSName() };
-is( $@, '', "Win32::GetOSName() in scalar context" );
-cmp_ok( length($osname), '>', 3, " - checking returned OS name" );
-
-# - list context
-my ($osname2, $desc) = eval { Win32::GetOSName() };
-is( $@, '', "Win32::GetOSName() in list context" );
-cmp_ok( length($osname2), '>', 3, " - checking returned OS name" );
-ok( defined($desc), " - checking returned description" );
-is( $osname2, $osname, " - checking that OS name is the same in both calls" );
-
-# test Win32::LoginName()
-my $login = eval { Win32::LoginName() };
-is( $@, '', "Win32::LoginName()" );
-cmp_ok( length($login), '>', 1, " - checking returned login name" );
-
-# test Win32::NodeName()
-my $nodename = eval { Win32::NodeName() };
-is( $@, '', "Win32::NodeName()" );
-cmp_ok( length($nodename), '>', 1, " - checking returned node name" );
+use strict; +BEGIN { + eval "use Test::More"; + return unless $@; + print "1..0 # Skip: Test requires Test::More module\n"; + exit 0; +} +use Win32; + +my $tests = 14; +$tests += 2 if Win32::IsWinNT(); + +plan tests => $tests; + +# test Win32::DomainName() +if (Win32::IsWinNT()) { + my $domain = eval { Win32::DomainName() }; + SKIP: { + skip('The Workstation service has not been started', 2) if (Win32::GetLastError() == 2138); + is( $@, '', "Win32::DomainName()" ); + like( $domain, '/^[a-zA-Z0-9!@#$%^&()_\'{}.~-]+$/', " - checking returned domain" ); + } +} + +# test Win32::GetArchName() +$ENV{PROCESSOR_ARCHITECTURE} ||= "unknown"; +my $archname = eval { Win32::GetArchName() }; +is( $@, '', "Win32::GetArchName()" ); +cmp_ok( length($archname), '>=', 3, " - checking returned architecture name" ); + +# test Win32::GetChipName() +my $chipname = eval { Win32::GetChipName() }; +is( $@, '', "Win32::GetChipName()" ); +cmp_ok( length($chipname), '>=', 3, " - checking returned chip name" ); + +# test Win32::GetOSName() +# - scalar context +my $osname = eval { Win32::GetOSName() }; +is( $@, '', "Win32::GetOSName() in scalar context" ); +cmp_ok( length($osname), '>', 3, " - checking returned OS name" ); + +# - list context +my ($osname2, $desc) = eval { Win32::GetOSName() }; +is( $@, '', "Win32::GetOSName() in list context" ); +cmp_ok( length($osname2), '>', 3, " - checking returned OS name" ); +ok( defined($desc), " - checking returned description" ); +is( $osname2, $osname, " - checking that OS name is the same in both calls" ); + +# test Win32::LoginName() +my $login = eval { Win32::LoginName() }; +is( $@, '', "Win32::LoginName()" ); +cmp_ok( length($login), '>', 0, " - checking returned login name" ); + +# test Win32::NodeName() +my $nodename = eval { Win32::NodeName() }; +is( $@, '', "Win32::NodeName()" ); +cmp_ok( length($nodename), '>', 0, " - checking returned node name" ); diff --git a/gnu/usr.bin/perl/cpan/Win32/t/Unicode.t b/gnu/usr.bin/perl/cpan/Win32/t/Unicode.t index 35701426658..2d03fd6dcd2 100755 --- a/gnu/usr.bin/perl/cpan/Win32/t/Unicode.t +++ b/gnu/usr.bin/perl/cpan/Win32/t/Unicode.t @@ -1,85 +1,90 @@ -use strict;
-use Test;
-use Cwd qw(cwd);
-use Win32;
-
-BEGIN {
- unless (defined &Win32::BuildNumber && Win32::BuildNumber() >= 820 or $] >= 5.008009) {
- print "1..0 # Skip: Needs ActivePerl 820 or Perl 5.8.9 or later\n";
- exit 0;
- }
- if ((((Win32::FsType())[1] & 4) == 0) || (Win32::FsType() =~ /^FAT/)) {
- print "1..0 # Skip: Filesystem doesn't support Unicode\n";
- exit 0;
- }
- unless ((Win32::GetOSVersion())[1] > 4) {
- print "1..0 # Skip: Unicode support requires Windows 2000 or later\n";
- exit 0;
- }
-}
-
-my $home = Win32::GetCwd();
-my $cwd = cwd(); # may be a Cygwin path
-my $dir = "Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz";
-my $file = "$dir\\xyzzy \x{394}\x{419} plugh \x{5E7}\x{645}";
-
-sub cleanup {
- chdir($home);
- my $ansi = Win32::GetANSIPathName($file);
- unlink($ansi) if -f $ansi;
- $ansi = Win32::GetANSIPathName($dir);
- rmdir($ansi) if -d $ansi;
-}
-
-cleanup();
-END { cleanup() }
-
-plan test => 12;
-
-# Create Unicode directory
-Win32::CreateDirectory($dir);
-ok(-d Win32::GetANSIPathName($dir));
-
-# Create Unicode file
-Win32::CreateFile($file);
-ok(-f Win32::GetANSIPathName($file));
-
-# readdir() returns ANSI form of Unicode filename
-ok(opendir(my $dh, Win32::GetANSIPathName($dir)));
-while ($_ = readdir($dh)) {
- next if /^\./;
- ok($file, Win32::GetLongPathName("$dir\\$_"));
-}
-closedir($dh);
-
-# Win32::GetLongPathName() of the absolute path restores the Unicode dir name
-my $full = Win32::GetFullPathName($dir);
-my $long = Win32::GetLongPathName($full);
-
-ok($long, Win32::GetLongPathName($home)."\\$dir");
-
-# We can Win32::SetCwd() into the Unicode directory
-ok(Win32::SetCwd($dir));
-
-my $w32dir = Win32::GetCwd();
-# cwd() also returns a usable ANSI directory name
-my $subdir = cwd();
-
-# change back to home directory to make sure relative paths
-# in @INC continue to work
-ok(chdir($home));
-ok(Win32::GetCwd(), $home);
-
-ok(Win32::GetLongPathName($w32dir), $long);
-
-# cwd() on Cygwin returns a mapped path that we need to translate
-# back to a Windows path. Invoking `cygpath` on $subdir doesn't work.
-if ($^O eq "cygwin") {
- $subdir = Cygwin::posix_to_win_path($subdir, 1);
-}
-$subdir =~ s,/,\\,g;
-ok(Win32::GetLongPathName($subdir), $long);
-
-# We can chdir() into the Unicode directory if we use the ANSI name
-ok(chdir(Win32::GetANSIPathName($dir)));
-ok(Win32::GetLongPathName(Win32::GetCwd()), $long);
+use strict; +use Test; +use Config qw(%Config); +use Cwd qw(cwd); +use Encode qw(); +use Win32; + +BEGIN { + unless (defined &Win32::BuildNumber && Win32::BuildNumber() >= 820 or $] >= 5.008009) { + print "1..0 # Skip: Needs ActivePerl 820 or Perl 5.8.9 or later\n"; + exit 0; + } + if ((((Win32::FsType())[1] & 4) == 0) || (Win32::FsType() =~ /^FAT/)) { + print "1..0 # Skip: Filesystem doesn't support Unicode\n"; + exit 0; + } + unless ((Win32::GetOSVersion())[1] > 4) { + print "1..0 # Skip: Unicode support requires Windows 2000 or later\n"; + exit 0; + } +} + +my $home = Win32::GetCwd(); +my $cwd = cwd(); # may be a Cygwin path +my $dir = "Foo \x{394}\x{419} Bar \x{5E7}\x{645} Baz"; +my $file = "$dir\\xyzzy \x{394}\x{419} plugh \x{5E7}\x{645}"; + +sub cleanup { + chdir($home); + my $ansi = Win32::GetANSIPathName($file); + unlink($ansi) if -f $ansi; + $ansi = Win32::GetANSIPathName($dir); + rmdir($ansi) if -d $ansi; +} + +cleanup(); +END { cleanup() } + +plan test => 12; + +# Create Unicode directory +Win32::CreateDirectory($dir); +ok(-d Win32::GetANSIPathName($dir)); + +# Create Unicode file +Win32::CreateFile($file); +ok(-f Win32::GetANSIPathName($file)); + +# readdir() returns ANSI form of Unicode filename +ok(opendir(my $dh, Win32::GetANSIPathName($dir))); +while ($_ = readdir($dh)) { + next if /^\./; + # On Cygwin 1.7 readdir() returns the utf8 representation of the + # filename but doesn't turn on the SvUTF8 bit + Encode::_utf8_on($_) if $^O eq "cygwin" && $Config{osvers} !~ /^1.5/; + ok($file, Win32::GetLongPathName("$dir\\$_")); +} +closedir($dh); + +# Win32::GetLongPathName() of the absolute path restores the Unicode dir name +my $full = Win32::GetFullPathName($dir); +my $long = Win32::GetLongPathName($full); + +ok($long, Win32::GetLongPathName($home)."\\$dir"); + +# We can Win32::SetCwd() into the Unicode directory +ok(Win32::SetCwd($dir)); + +my $w32dir = Win32::GetCwd(); +# cwd() also returns a usable ANSI directory name +my $subdir = cwd(); + +# change back to home directory to make sure relative paths +# in @INC continue to work +ok(chdir($home)); +ok(Win32::GetCwd(), $home); + +ok(Win32::GetLongPathName($w32dir), $long); + +# cwd() on Cygwin returns a mapped path that we need to translate +# back to a Windows path. Invoking `cygpath` on $subdir doesn't work. +if ($^O eq "cygwin") { + $subdir = Cygwin::posix_to_win_path($subdir, 1); +} +$subdir =~ s,/,\\,g; +ok(Win32::GetLongPathName($subdir), $long); + +# We can chdir() into the Unicode directory if we use the ANSI name +ok(chdir(Win32::GetANSIPathName($dir))); +ok(Win32::GetLongPathName(Win32::GetCwd()), $long); |