| 1 |
#!./perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use Scalar::Util qw(blessed reftype refaddr); |
| 7 |
use Test::More tests => 6; |
| 8 |
|
| 9 |
my $getmagic_count; |
| 10 |
|
| 11 |
{ |
| 12 |
package T; |
| 13 |
use Tie::Scalar; |
| 14 |
use base qw(Tie::StdScalar); |
| 15 |
|
| 16 |
sub FETCH { |
| 17 |
$getmagic_count++; |
| 18 |
my($self) = @_; |
| 19 |
return $self->SUPER::FETCH; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
tie my $var, 'T'; |
| 24 |
|
| 25 |
$var = bless {}; |
| 26 |
|
| 27 |
$getmagic_count = 0; |
| 28 |
ok blessed($var); |
| 29 |
is $getmagic_count, 1, 'blessed'; |
| 30 |
|
| 31 |
$getmagic_count = 0; |
| 32 |
ok reftype($var); |
| 33 |
is $getmagic_count, 1, 'reftype'; |
| 34 |
|
| 35 |
$getmagic_count = 0; |
| 36 |
ok refaddr($var); |
| 37 |
is $getmagic_count, 1, 'refaddr'; |