Fix for [perl #34252] Access rights in FindBin::Bin
[p5sagit/p5-mst-13.2.git] / lib / FileCache / t / 06export.t
1 #!./perl
2 BEGIN {
3     chdir 't' if -d 't';
4
5     #For tests within the perl distribution
6     @INC = '../lib' if -d '../lib';
7     END;
8
9     # Functions exported by FileCache;
10     @funcs  = qw[cacheout cacheout_close];
11     $i      = 0;
12     
13     # number of tests
14     print "1..8\n";
15 }
16
17 # Test 6: Test that exporting both works to package main and
18 # other packages. Now using Exporter.
19
20 # First, we shouldn't be able to have these in our namespace
21 # Add them to BEGIN so the later 'use' doesn't influence this
22 # test
23 BEGIN {   
24     for my $f (@funcs) {
25         ++$i;
26         print 'not ' if __PACKAGE__->can($f);
27         print "ok $i\n"; 
28     }
29 }
30
31 # With an empty import list, we also shouldn't have them in
32 # our namespace.
33 # Add them to BEGIN so the later 'use' doesn't influence this
34 # test
35 BEGIN {   
36     use FileCache ();
37     for my $f (@funcs) {
38         ++$i;
39         print 'not ' if __PACKAGE__->can($f);
40         print "ok $i\n"; 
41     }
42 }
43
44
45 # Now, we use FileCache in 'main'
46 {   use FileCache;
47     for my $f (@funcs) {
48         ++$i;
49         print 'not ' if !__PACKAGE__->can($f);
50         print "ok $i\n"; 
51     }
52 }
53
54 # Now we use them in another package
55 {   package X;
56     use FileCache;
57     for my $f (@main::funcs) {
58         ++$main::i;
59         print 'not ' if !__PACKAGE__->can($f);
60         print "ok $main::i\n"; 
61     }
62 }