skip test if db doesn't have null key support
[p5sagit/p5-mst-13.2.git] / t / lib / glob-global.t
CommitLineData
72b16652 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 unshift @INC, '../lib';
d2a01882 6 require Config; import Config;
7 if ($Config{'extensions'} !~ /\bFile\/Glob\b/i) {
8 print "1..0\n";
9 exit 0;
10 }
72b16652 11 print "1..10\n";
12}
13END {
14 print "not ok 1\n" unless $loaded;
15}
16
17BEGIN {
18 *CORE::GLOBAL::glob = sub { "Just another Perl hacker," };
19}
20
21BEGIN {
22 if ("Just another Perl hacker," ne (<*>)[0]) {
23 die <<EOMessage;
24Your version of perl ($]) doesn't seem to allow extensions to override
25the core glob operator.
26EOMessage
27 }
28}
29
220398a0 30use File::Glob ':globally';
72b16652 31$loaded = 1;
32print "ok 1\n";
33
34$_ = "lib/*.t";
35my @r = glob;
36print "not " if $_ ne 'lib/*.t';
37print "ok 2\n";
38
39# we should have at least basic.t, global.t, taint.t
40print "# |@r|\nnot " if @r < 3;
41print "ok 3\n";
42
43# check if <*/*> works
44@r = <*/*.t>;
45# at least t/global.t t/basic.t, t/taint.t
46print "not " if @r < 3;
47print "ok 4\n";
48my $r = scalar @r;
49
50# check if scalar context works
51@r = ();
52while (defined($_ = <*/*.t>)) {
53 #print "# $_\n";
54 push @r, $_;
55}
56print "not " if @r != $r;
57print "ok 5\n";
58
59# check if array context works
60@r = ();
61for (<*/*.t>) {
62 #print "# $_\n";
63 push @r, $_;
64}
65print "not " if @r != $r;
66print "ok 6\n";
67
68# test if implicit assign to $_ in while() works
69@r = ();
70while (<*/*.t>) {
71 #print "# $_\n";
72 push @r, $_;
73}
74print "not " if @r != $r;
75print "ok 7\n";
76
77# test if explicit glob() gets assign magic too
78my @s = ();
79while (glob '*/*.t') {
80 #print "# $_\n";
81 push @s, $_;
82}
83print "not " if "@r" ne "@s";
84print "ok 8\n";
85
86# how about in a different package, like?
87package Foo;
220398a0 88use File::Glob ':globally';
72b16652 89@s = ();
90while (glob '*/*.t') {
91 #print "# $_\n";
92 push @s, $_;
93}
94print "not " if "@r" ne "@s";
95print "ok 9\n";
96
97# test if different glob ops maintain independent contexts
98@s = ();
99my $i = 0;
100while (<*/*.t>) {
101 #print "# $_ <";
102 push @s, $_;
103 while (<bas*/*.t>) {
104 #print " $_";
105 $i++;
106 }
107 #print " >\n";
108}
109print "not " if "@r" ne "@s" or not $i;
110print "ok 10\n";