xref: /openbsd-src/gnu/usr.bin/perl/cpan/Scalar-List-Utils/t/getmagic-once.t (revision b8851fcc53cbe24fd20b090f26dd149e353f6174)
1#!./perl
2
3use strict;
4use warnings;
5
6use Scalar::Util qw(blessed reftype refaddr);
7use Test::More tests => 6;
8
9my $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
23tie my $var, 'T';
24
25$var = bless {};
26
27$getmagic_count = 0;
28ok blessed($var);
29is $getmagic_count, 1, 'blessed';
30
31$getmagic_count = 0;
32ok reftype($var);
33is $getmagic_count, 1, 'reftype';
34
35$getmagic_count = 0;
36ok refaddr($var);
37is $getmagic_count, 1, 'refaddr';
38