— |
subtest "tied scalar" => sub
{
tie my ( $int ), Int;
is(
exception { $int = 42 },
undef ,
);
isnt(
exception { $int = 4.2 },
undef ,
);
is( $int , 42);
done_testing;
};
subtest "tied array" => sub
{
tie my ( @ints ), Int;
is(
exception {
$ints [0] = 1;
push @ints , 2;
unshift @ints , 0;
},
undef ,
);
isnt(
exception { $ints [3] = 3.5 },
undef ,
);
is_deeply(
\ @ints ,
[ 0..2 ],
);
done_testing;
};
subtest "tied hash" => sub
{
tie my ( %ints ), Int;
is(
exception {
$ints {one} = 1;
$ints {two} = 2;
},
undef ,
);
isnt(
exception { $ints {three} = 3.5 },
undef ,
);
is_deeply(
\ %ints ,
{ one => 1, two => 2 },
);
done_testing;
};
done_testing;
|