Subject: | NEW Tk: perl/Tk Problem with referenced variable in Entry |
Date: | Thu, 4 May 2017 11:07:43 -0600 |
To: | bug-Tk [...] rt.cpan.org |
From: | Roman Royer <romanroyer [...] yahoo.com> |
Distribution: Tk 804.033
Perl Version: 5.24.1
OS: Linux raroyer-lnx 2.6.18-400.1.1.el5 #1 SMP Sun Dec 14 06:01:17 EST
2014 x86_64 x86_64 x86_64 GNU/Linux
This new bug is very similar to this previous bug:
https://rt.cpan.org/Public/Bug/Display.html?id=90077
which had this test added:
https://github.com/eserte/perl-tk/commit/f978a133908ef715233ace871919aff5aeb93254?diff=unified
However, by changing just two lines in the test case, it fails in the
latest perl/Tk.
After tying a variable containing a float to an Entry box, NOT destroying
the Entry box, and then multiplying the variable by 1.0, the variable is no
longer treated as a float correctly. This does NOT fail on perl <= 5.16,
but fails on perl >= 5.18, which corresponds to when perl #90077 was fixed.
*Failing Test Case (slight modification of #90077 Test Case):*
use strict;
use Test::More 'no_plan';
use Tk;
my $mw = tkinit;
$mw->geometry('+0+0');
{
# RT #90077
my $val = 0.20;
{ no warnings 'void'; $val * 2 }
is $val * 1, 0.20;
{
my $tl = $mw->Toplevel;
$tl->Entry(-textvariable => \$val)->pack;
* #$tl->destroy; # Line Modified: Only fails if Toplevel is not
destroyed*
}
* $val * 1.0; # Line Added: This causes $val to be incorrectly
interpreted as integer in future operations*
is $val * 1, 0.20 or
do { require Devel::Peek; Devel::Peek::Dump($val) }; # pv_dump says:
FLAGS = (PADMY,IOK,NOK,POK,pIOK,pNOK,pPOK,UTF8)
}
__END__
*Test Case Output:*
ok 1
not ok 2
# Failed test at test2.pl line 25.
# got: '0'
# expected: '0.2'
SV = PVMG(0xf0ac0f0) at 0xe912070
REFCNT = 2
FLAGS = (GMG,SMG,IOK,NOK,POK,pIOK,pNOK,pPOK,UTF8)
IV = 0
NV = 0.2
PV = 0xf093cb0 "0.2"\0 [UTF8 "0.2"]
CUR = 3
LEN = 32
MAGIC = 0xf093d10
MG_VIRTUAL = &PL_vtbl_uvar
MG_TYPE = PERL_MAGIC_uvar(U)
MG_LEN = 24
MG_PTR = 0xf0b2470 " \342C/\372*\0\0\300\vD/\372*\0\0\260;\f\17\0\0\0\0"
1..2
# Looks like you failed 1 test of 2.