summaryrefslogtreecommitdiff
path: root/lib/FileCache
diff options
context:
space:
mode:
authorJos I. Boumans <kane@dwim.org>2004-12-08 15:24:19 +0100
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-12-08 16:19:38 +0000
commit02c473a9139e94d6158d1e3dd9a912f3525b3b21 (patch)
treeadac38cd67e7893db531aea52b5279e409513741 /lib/FileCache
parentb7a91edcc80cb05776e70aedec8ffa365b6d6806 (diff)
downloadperl-02c473a9139e94d6158d1e3dd9a912f3525b3b21.tar.gz
Re: [perl #32949] FileCache only works in "main" package
From: "Jos I. Boumans" <kane@xs4all.net> Message-Id: <7728A4F5-491C-11D9-9CA3-000A95EF62E2@xs4all.net> p4raw-id: //depot/perl@23627
Diffstat (limited to 'lib/FileCache')
-rw-r--r--lib/FileCache/t/06export.t62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/FileCache/t/06export.t b/lib/FileCache/t/06export.t
new file mode 100644
index 0000000000..60f55a3182
--- /dev/null
+++ b/lib/FileCache/t/06export.t
@@ -0,0 +1,62 @@
+#!./perl
+BEGIN {
+ chdir 't' if -d 't';
+
+ #For tests within the perl distribution
+ @INC = '../lib' if -d '../lib';
+ END;
+
+ # Functions exported by FileCache;
+ @funcs = qw[cacheout cacheout_close];
+ $i = 0;
+
+ # number of tests
+ print "1..8\n";
+}
+
+# Test 6: Test that exporting both works to package main and
+# other packages. Now using Exporter.
+
+# First, we shouldn't be able to have these in our namespace
+# Add them to BEGIN so the later 'use' doesn't influence this
+# test
+BEGIN {
+ for my $f (@funcs) {
+ ++$i;
+ print 'not ' if __PACKAGE__->can($f);
+ print "ok $i\n";
+ }
+}
+
+# With an empty import list, we also shouldn't have them in
+# our namespace.
+# Add them to BEGIN so the later 'use' doesn't influence this
+# test
+BEGIN {
+ use FileCache ();
+ for my $f (@funcs) {
+ ++$i;
+ print 'not ' if __PACKAGE__->can($f);
+ print "ok $i\n";
+ }
+}
+
+
+# Now, we use FileCache in 'main'
+{ use FileCache;
+ for my $f (@funcs) {
+ ++$i;
+ print 'not ' if !__PACKAGE__->can($f);
+ print "ok $i\n";
+ }
+}
+
+# Now we use them in another package
+{ package X;
+ use FileCache;
+ for my $f (@main::funcs) {
+ ++$main::i;
+ print 'not ' if !__PACKAGE__->can($f);
+ print "ok $main::i\n";
+ }
+}