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