diff options
-rw-r--r-- | ext/List/Util/t/readonly.t | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/List/Util/t/readonly.t b/ext/List/Util/t/readonly.t index a515f2e3f3..7415759010 100644 --- a/ext/List/Util/t/readonly.t +++ b/ext/List/Util/t/readonly.t @@ -14,7 +14,7 @@ BEGIN { } use Scalar::Util qw(readonly); -use Test::More tests => 9; +use Test::More tests => 11; ok( readonly(1), 'number constant'); @@ -36,3 +36,14 @@ ok( !readonly($var), 'reference to constant'); ok( readonly($$var), 'de-reference to constant'); ok( !readonly(*STDOUT), 'glob'); + +sub try +{ + my $v = \$_[0]; + return readonly $$v; +} + +$var = 123; +ok( try ("abc"), 'reference a constant in a sub'); +ok( !try ($var), 'reference a non-constant in a sub'); + |