tests for nonexistent hash/array entries
Jesse Luehrs [Wed, 12 May 2010 03:44:10 +0000 (22:44 -0500)]
t/004-get.t [new file with mode: 0644]

diff --git a/t/004-get.t b/t/004-get.t
new file mode 100644 (file)
index 0000000..c38ae65
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+use Stash::Manip;
+
+{
+    my $stash = Stash::Manip->new('Foo');
+    my $val = $stash->get_package_symbol('%foo');
+    is(ref($val), 'HASH', "got something");
+    $val->{bar} = 1;
+    is_deeply($stash->get_package_symbol('%foo'), {bar => 1},
+              "got the right variable");
+}
+
+{
+    my $stash = Stash::Manip->new('Bar');
+    my $val = $stash->get_package_symbol('@foo');
+    is(ref($val), 'ARRAY', "got something");
+    push @$val, 1;
+    is_deeply($stash->get_package_symbol('@foo'), [1],
+              "got the right variable");
+}
+
+done_testing;