summaryrefslogtreecommitdiff
path: root/ext/File-Glob/t/basic.t
diff options
context:
space:
mode:
Diffstat (limited to 'ext/File-Glob/t/basic.t')
-rw-r--r--ext/File-Glob/t/basic.t36
1 files changed, 35 insertions, 1 deletions
diff --git a/ext/File-Glob/t/basic.t b/ext/File-Glob/t/basic.t
index ed8301900f..dffffc8556 100644
--- a/ext/File-Glob/t/basic.t
+++ b/ext/File-Glob/t/basic.t
@@ -10,7 +10,7 @@ BEGIN {
}
}
use strict;
-use Test::More tests => 15;
+use Test::More tests => 18;
BEGIN {use_ok('File::Glob', ':glob')};
use Cwd ();
@@ -68,6 +68,40 @@ SKIP: {
is_deeply (\@a, [$home]);
}
}
+# check plain tilde expansion
+{
+ my $tilde_check = sub {
+ my @a = bsd_glob('~');
+
+ if (GLOB_ERROR) {
+ fail(GLOB_ERROR);
+ } else {
+ is_deeply (\@a, [$_[0]], join ' - ', 'tilde expansion', @_ > 1 ? $_[1] : ());
+ }
+ };
+ my $passwd_home = eval { (getpwuid($>))[7] };
+
+ {
+ local %ENV = %ENV;
+ delete $ENV{HOME};
+ delete $ENV{USERPROFILE};
+ $tilde_check->(defined $passwd_home ? $passwd_home : q{~}, 'no environment');
+ }
+
+ SKIP: {
+ skip 'MSWin32 only', 1 if $^O ne 'MSWin32';
+ local %ENV = %ENV;
+ delete $ENV{HOME};
+ $ENV{USERPROFILE} = 'sweet win32 home';
+ $tilde_check->(defined $passwd_home ? $passwd_home : $ENV{USERPROFILE}, 'USERPROFILE');
+ }
+
+ my $home = exists $ENV{HOME} ? $ENV{HOME}
+ : eval { getpwuid($>); 1 } ? (getpwuid($>))[7]
+ : $^O eq 'MSWin32' && exists $ENV{USERPROFILE} ? $ENV{USERPROFILE}
+ : q{~};
+ $tilde_check->($home);
+}
# check backslashing
# should return a list with one item, and not set ERROR