From 3634ce60eff13a438a24efd8b61192aadff7d0de Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 11 May 2010 22:11:15 -0500 Subject: error when trying to init a stash slot with a value of the wrong type --- t/001-basic.t | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 't') diff --git a/t/001-basic.t b/t/001-basic.t index 52ddfaa..ef95bf1 100644 --- a/t/001-basic.t +++ b/t/001-basic.t @@ -225,4 +225,27 @@ is($foo_stash->get_package_symbol('@foo'), $ARRAY, '... got the right values for ok(defined(*{"Foo::foo"}{ARRAY}), '... the @foo slot has NOT been removed'); } +# check some errors + +dies_ok { + $foo_stash->add_package_symbol('@bar', {}) +} "can't initialize a slot with the wrong type of value"; + +dies_ok { + $foo_stash->add_package_symbol('bar', []) +} "can't initialize a slot with the wrong type of value"; + +dies_ok { + $foo_stash->add_package_symbol('$bar', sub { }) +} "can't initialize a slot with the wrong type of value"; + +{ + package Bar; + open *foo, '<', $0; +} + +dies_ok { + $foo_stash->add_package_symbol('$bar', *Bar::foo{IO}) +} "can't initialize a slot with the wrong type of value"; + done_testing; -- cgit v1.2.3-54-g00ecf