From c74b32e11eab9b135a69e56025b7a6a7c7514ea8 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 15 Jun 2013 20:41:49 -0700 Subject: Test readonliness of overload constants including one to-do test --- lib/overload.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/overload.t') diff --git a/lib/overload.t b/lib/overload.t index 74adae340e..aa99cc298b 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl' } -plan tests => 5191; +plan tests => 5193; use Scalar::Util qw(tainted); @@ -1292,6 +1292,20 @@ foreach my $op (qw(<=> == != < <= > >=)) { is(eval "17", $twenty_three); } +{ + # Check readonliness of constants, whether shared hash key + # scalars or no (brought up in bug #109744) + BEGIN { overload::constant integer => sub { "main" }; } + eval { ${\5} = 'whatever' }; + like $@, qr/^Modification of a read-only value attempted at /, + 'constant overloading makes read-only constants'; + BEGIN { overload::constant integer => sub { __PACKAGE__ }; } + eval { ${\5} = 'whatever' }; + local $::TODO = ' '; + like $@, qr/^Modification of a read-only value attempted at /, + '... even with shared hash key scalars'; +} + { package Sklorsh; use overload -- cgit v1.2.1