summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/lib/env-array.t100
-rwxr-xr-xt/lib/env.t11
-rwxr-xr-xt/lib/filefind.t64
-rwxr-xr-xt/lib/glob-basic.t2
4 files changed, 172 insertions, 5 deletions
diff --git a/t/lib/env-array.t b/t/lib/env-array.t
new file mode 100755
index 0000000000..d90d89226f
--- /dev/null
+++ b/t/lib/env-array.t
@@ -0,0 +1,100 @@
+#!./perl
+
+$| = 1;
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+if ($^O eq 'VMS') {
+ print "1..11\n";
+ foreach (1..11) { print "ok $_ # skipped for VMS\n"; }
+ exit 0;
+}
+
+use Env qw(@FOO);
+use vars qw(@BAR);
+
+sub array_equal
+{
+ my ($a, $b) = @_;
+ return 0 unless scalar(@$a) == scalar(@$b);
+ for my $i (0..scalar(@$a) - 1) {
+ return 0 unless $a->[$i] eq $b->[$i];
+ }
+ return 1;
+}
+
+sub test
+{
+ my ($desc, $code) = @_;
+
+ &$code;
+
+ print "# $desc...\n";
+ print "# FOO = (", join(", ", @FOO), ")\n";
+ print "# BAR = (", join(", ", @BAR), ")\n";
+
+ if (defined $check) { print "not " unless &$check; }
+ else { print "not " unless array_equal(\@FOO, \@BAR); }
+
+ print "ok ", ++$i, "\n";
+}
+
+print "1..11\n";
+
+test "Assignment", sub {
+ @FOO = qw(a B c);
+ @BAR = qw(a B c);
+};
+
+test "Storing", sub {
+ $FOO[1] = 'b';
+ $BAR[1] = 'b';
+};
+
+test "Truncation", sub {
+ $#FOO = 0;
+ $#BAR = 0;
+};
+
+test "Push", sub {
+ push @FOO, 'b', 'c';
+ push @BAR, 'b', 'c';
+};
+
+test "Pop", sub {
+ pop @FOO;
+ pop @BAR;
+};
+
+test "Shift", sub {
+ shift @FOO;
+ shift @BAR;
+};
+
+test "Push", sub {
+ push @FOO, 'c';
+ push @BAR, 'c';
+};
+
+test "Unshift", sub {
+ unshift @FOO, 'a';
+ unshift @BAR, 'a';
+};
+
+test "Reverse", sub {
+ @FOO = reverse @FOO;
+ @BAR = reverse @BAR;
+};
+
+test "Sort", sub {
+ @FOO = sort @FOO;
+ @BAR = sort @BAR;
+};
+
+test "Splice", sub {
+ splice @FOO, 1, 1, 'B';
+ splice @BAR, 1, 1, 'B';
+};
diff --git a/t/lib/env.t b/t/lib/env.t
index 93d24066e6..25731648a0 100755
--- a/t/lib/env.t
+++ b/t/lib/env.t
@@ -7,12 +7,19 @@ BEGIN {
BEGIN {
$ENV{FOO} = "foo";
+ $ENV{BAR} = "bar";
}
-use Env qw(FOO);
+use Env qw(FOO $BAR);
$FOO .= "/bar";
+$BAR .= "/baz";
+
+print "1..2\n";
-print "1..1\n";
print "not " if $FOO ne 'foo/bar';
print "ok 1\n";
+
+print "not " if $BAR ne 'bar/baz';
+print "ok 2\n";
+
diff --git a/t/lib/filefind.t b/t/lib/filefind.t
index 8e57aec673..89999fdee7 100755
--- a/t/lib/filefind.t
+++ b/t/lib/filefind.t
@@ -9,8 +9,8 @@ BEGIN {
unshift @INC, '../lib';
}
-if ( $symlink_exists ) { print "1..59\n"; }
-else { print "1..31\n"; }
+if ( $symlink_exists ) { print "1..117\n"; }
+else { print "1..61\n"; }
use File::Find;
@@ -29,6 +29,8 @@ END {
rmdir 'fa';
rmdir 'fb/fba';
rmdir 'fb';
+ chdir '..';
+ rmdir 'for_find';
}
sub Check($) {
@@ -58,6 +60,31 @@ sub wanted {
$File::Find::prune=1 if $_ eq 'faba';
}
+sub dn_wanted {
+ my $n = $File::Find::name;
+ print "# '$n' => 1\n";
+ my $i = rindex($n,'/');
+ my $OK = exists($Expect{$n});
+ if ( $OK ) {
+ $OK= exists($Expect{substr($n,0,$i)}) if $i >= 0;
+ }
+ Check($OK);
+ delete $Expect{$n};
+}
+
+sub d_wanted {
+ print "# '$_' => 1\n";
+ my $i = rindex($_,'/');
+ my $OK = exists($Expect{$_});
+ if ( $OK ) {
+ $OK= exists($Expect{substr($_,0,$i)}) if $i >= 0;
+ }
+ Check($OK);
+ delete $Expect{$_};
+}
+
+MkDir( 'for_find',0770 );
+CheckDie(chdir(for_find));
MkDir( 'fa',0770 );
MkDir( 'fb',0770 );
touch('fb/fb_ord');
@@ -87,6 +114,22 @@ File::Find::find( {wanted => \&wanted, no_chdir => 1},'fa' );
Check( scalar(keys %Expect) == 0 );
+%Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1,
+ './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1,
+ './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1,
+ './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1);
+delete $Expect{'./fa/fsl'} unless $symlink_exists;
+File::Find::finddepth( {wanted => \&dn_wanted },'.' );
+Check( scalar(keys %Expect) == 0 );
+
+%Expect=('.' => 1, './fa' => 1, './fa/fsl' => 1, './fa/fa_ord' => 1, './fa/fab' => 1,
+ './fa/fab/fab_ord' => 1, './fa/fab/faba' => 1,
+ './fa/fab/faba/faba_ord' => 1, './fa/faa' => 1, './fa/faa/faa_ord' => 1,
+ './fb' => 1, './fb/fba' => 1, './fb/fba/fba_ord' => 1, './fb/fb_ord' => 1);
+delete $Expect{'./fa/fsl'} unless $symlink_exists;
+File::Find::finddepth( {wanted => \&d_wanted, no_chdir => 1 },'.' );
+Check( scalar(keys %Expect) == 0 );
+
if ( $symlink_exists ) {
%Expect=('.' => 1, 'fa_ord' => 1, 'fsl' => 1, 'fb_ord' => 1, 'fba' => 1,
'fba_ord' => 1, 'fab' => 1, 'fab_ord' => 1, 'faba' => 1, 'faa' => 1,
@@ -94,12 +137,29 @@ if ( $symlink_exists ) {
File::Find::find( {wanted => \&wanted, follow_fast => 1},'fa' );
Check( scalar(keys %Expect) == 0 );
+
%Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
File::Find::find( {wanted => \&wanted, follow_fast => 1, no_chdir => 1},'fa' );
Check( scalar(keys %Expect) == 0 );
+
+ %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
+ 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
+ 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
+ 'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
+
+ File::Find::finddepth( {wanted => \&dn_wanted, follow_fast => 1},'fa' );
+ Check( scalar(keys %Expect) == 0 );
+
+ %Expect=('fa' => 1, 'fa/fa_ord' => 1, 'fa/fsl' => 1, 'fa/fsl/fb_ord' => 1,
+ 'fa/fsl/fba' => 1, 'fa/fsl/fba/fba_ord' => 1, 'fa/fab' => 1,
+ 'fa/fab/fab_ord' => 1, 'fa/fab/faba' => 1, 'fa/fab/faba/faba_ord' => 1,
+ 'fa/faa' => 1, 'fa/faa/faa_ord' => 1);
+
+ File::Find::finddepth( {wanted => \&d_wanted, follow_fast => 1, no_chdir => 1},'fa' );
+ Check( scalar(keys %Expect) == 0 );
}
print "# of cases: $case\n";
diff --git a/t/lib/glob-basic.t b/t/lib/glob-basic.t
index 2336fc0d9b..b967e8d033 100755
--- a/t/lib/glob-basic.t
+++ b/t/lib/glob-basic.t
@@ -72,7 +72,7 @@ print "ok 5\n";
# check bad protections
# should return an empty list, and set ERROR
-if ($^O eq 'mpeix' or $^O eq 'MSWin32' or $^O eq 'os2' or $^O eq 'VMS' or not $>) {
+if ($^O eq 'mpeix' or $^O eq 'MSWin32' or $^O eq 'os2' or $^O eq 'VMS' or $^O eq 'cygwin' or not $>) {
print "ok 6 # skipped\n";
}
else {