The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
use strict;
use Test::More;
use Tk;
plan tests => 7;
my $var = 'One';
my $mw = MainWindow->new;
my $e  = $mw->Entry(-textvariable => \$var)->pack;
is($e->get,$var,"Entry initialized from variable");
$e->delete(0,'end');
is($var,'',"Delete changes variable");
$e->insert(0,'Two');
is($var,'Two',"Insert changes variable");
$var = 'Three';
is($e->get,$var,"Entry tracks variable assignment");
chop($var);
is($e->get,'Thre',"Entry tracks chop-ing variable");

my $nv;
$mw->Entry(-textvariable => \$nv);
$nv = 3/2;
is($nv, 3/2, "IV does not override NV");

my $pv_chop = 421;
chop($pv_chop);
$mw->Entry(-textvariable => \$pv_chop);
is($pv_chop, "42", "PV flag set");

__END__