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