summaryrefslogtreecommitdiffstats
path: root/t/003-io.t
diff options
context:
space:
mode:
Diffstat (limited to 't/003-io.t')
-rw-r--r--t/003-io.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/003-io.t b/t/003-io.t
new file mode 100644
index 0000000..a41b2ae
--- /dev/null
+++ b/t/003-io.t
@@ -0,0 +1,50 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Exception;
+
+{
+ package Foo;
+ open *foo, "<", $0;
+
+ sub foo { }
+}
+
+{
+ package Bar;
+ open *bar, "<", $0;
+
+ sub bar { }
+}
+
+use Stash::Manip;
+
+{
+ my $stash = Stash::Manip->new('Foo');
+ ok($stash->has_package_symbol('&foo'), "has &foo");
+ ok($stash->has_package_symbol('foo'), "has foo");
+ $stash->remove_package_symbol('&foo');
+ ok(!$stash->has_package_symbol('&foo'), "has &foo");
+ ok($stash->has_package_symbol('foo'), "has foo");
+}
+
+{
+ my $stash = Stash::Manip->new('Bar');
+ ok($stash->has_package_symbol('&bar'), "has &bar");
+ ok($stash->has_package_symbol('bar'), "has bar");
+ $stash->remove_package_symbol('bar');
+ ok($stash->has_package_symbol('&bar'), "has &bar");
+ ok(!$stash->has_package_symbol('bar'), "has bar");
+}
+
+{
+ my $stash = Stash::Manip->new('Baz');
+ lives_ok {
+ $stash->add_package_symbol('baz', *Foo::foo{IO});
+ } "can add an IO symbol";
+ ok($stash->has_package_symbol('baz'), "has baz");
+ is($stash->get_package_symbol('baz'), *Foo::foo{IO}, "got the right baz");
+}
+
+done_testing;