xref: /openbsd/gnu/usr.bin/perl/ext/FileCache/t/06export.t (revision 3d8817e4)
1#!./perl
2use vars qw(@funcs $i);
3
4BEGIN {
5    # Functions exported by FileCache;
6    @funcs  = qw[cacheout cacheout_close];
7    $i      = 0;
8}
9
10use Test::More tests => 8;
11
12# Test 6: Test that exporting both works to package main and
13# other packages. Now using Exporter.
14
15# First, we shouldn't be able to have these in our namespace
16# Add them to BEGIN so the later 'use' doesn't influence this
17# test
18BEGIN {
19    ok(not __PACKAGE__->can($_)) foreach @funcs;
20}
21
22# With an empty import list, we also shouldn't have them in
23# our namespace.
24# Add them to BEGIN so the later 'use' doesn't influence this
25# test
26BEGIN {
27    use FileCache ();
28    ok(not __PACKAGE__->can($_)) foreach @funcs;
29}
30
31
32# Now, we use FileCache in 'main'
33{
34    use FileCache;
35    ok(__PACKAGE__->can($_)) foreach @funcs;
36}
37
38# Now we use them in another package
39{
40    package X;
41    use FileCache;
42    ::ok(__PACKAGE__->can($_)) foreach @main::funcs;
43}
44
45