#!./perl
#
# test glob() in File::DosGlob
#
BEGIN {
chdir 't' if -d 't';
}
print "1..10\n";
# override it in main::
# test if $_ takes as the default
my $expected;
} else {
}
my @r = glob;
print "ok 1\n";
print "# |@r|\nnot " if @r < 9;
print "ok 2\n";
# check if <*/*> works
@r = <:*:a*.t>;
} else {
@r = <*/a*.t>;
}
# atleast {argv,abbrev,anydbm,autoloader,append,arith,array,assignwarn,auto}.t
print "# |@r|\nnot " if @r < 9;
print "ok 3\n";
my $r = scalar @r;
# check if scalar context works
@r = ();
print "# $_\n";
push @r, $_;
}
print "not " if @r != $r;
print "ok 4\n";
# check if list context works
@r = ();
for (<:*:a*.t>) {
print "# $_\n";
push @r, $_;
}
} else {
for (<*/a*.t>) {
print "# $_\n";
push @r, $_;
}
}
print "not " if @r != $r;
print "ok 5\n";
# test if implicit assign to $_ in while() works
@r = ();
while (<:*:a*.t>) {
print "# $_\n";
push @r, $_;
}
} else {
while (<*/a*.t>) {
print "# $_\n";
push @r, $_;
}
}
print "not " if @r != $r;
print "ok 6\n";
# test if explicit glob() gets assign magic too
my @s = ();
print "# $_\n";
push @s, $_;
}
print "ok 7\n";
# how about in a different package, like?
@s = ();
print "# $_\n";
push @s, $_;
}
print "ok 8\n";
# test if different glob ops maintain independent contexts
@s = ();
while (<:*:a*.t>) {
my $i = 0;
print "# $_ <";
push @s, $_;
while (<:*:b*.t>) {
print " $_";
$i++;
}
print " >\n";
}
} else {
while (<*/a*.t>) {
my $i = 0;
print "# $_ <";
push @s, $_;
while (<*/b*.t>) {
print " $_";
$i++;
}
print " >\n";
}
}
print "ok 9\n";
# how about a global override, hm?
eval <<'EOT';
@s = ();
while (<:*:a*.t>) {
my $i = 0;
print "# $_ <";
push @s, $_;
while (glob ':*:b*.t') {
print " $_";
$i++;
}
print " >\n";
}
} else {
while (<*/a*.t>) {
my $i = 0;
print "# $_ <";
push @s, $_;
while (glob '*/b*.t') {
print " $_";
$i++;
}
print " >\n";
}
}
print "ok 10\n";