summaryrefslogtreecommitdiff
path: root/lib/Internals.t
blob: e8abebbb2d3842c41c16a111307b29b9432d5eef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl -Tw

BEGIN {
    if( $ENV{PERL_CORE} ) {
        @INC = '../lib';
        chdir 't';
    }
}

use Test::More tests => 33;

my $foo;
my @foo;
my %foo;

ok( !Internals::SvREADONLY $foo );
ok(  Internals::SvREADONLY $foo, 1 );
ok(  Internals::SvREADONLY $foo );
ok( !Internals::SvREADONLY $foo, 0 );
ok( !Internals::SvREADONLY $foo );

ok( !Internals::SvREADONLY @foo );
ok(  Internals::SvREADONLY @foo, 1 );
ok(  Internals::SvREADONLY @foo );
ok( !Internals::SvREADONLY @foo, 0 );
ok( !Internals::SvREADONLY @foo );

ok( !Internals::SvREADONLY $foo[2] );
ok(  Internals::SvREADONLY $foo[2], 1 );
ok(  Internals::SvREADONLY $foo[2] );
ok( !Internals::SvREADONLY $foo[2], 0 );
ok( !Internals::SvREADONLY $foo[2] );

ok( !Internals::SvREADONLY %foo );
ok(  Internals::SvREADONLY %foo, 1 );
ok(  Internals::SvREADONLY %foo );
ok( !Internals::SvREADONLY %foo, 0 );
ok( !Internals::SvREADONLY %foo );

ok( !Internals::SvREADONLY $foo{foo} );
ok(  Internals::SvREADONLY $foo{foo}, 1 );
ok(  Internals::SvREADONLY $foo{foo} );
ok( !Internals::SvREADONLY $foo{foo}, 0 );
ok( !Internals::SvREADONLY $foo{foo} );

is(  Internals::SvREFCNT($foo), 1 );
{
    my $bar = \$foo;
    is(  Internals::SvREFCNT($foo), 2 );
    is(  Internals::SvREFCNT($bar), 1 );
}
is(  Internals::SvREFCNT($foo), 1 );

is(  Internals::SvREFCNT(@foo), 1 );
is(  Internals::SvREFCNT($foo[2]), 1 );
is(  Internals::SvREFCNT(%foo), 1 );
is(  Internals::SvREFCNT($foo{foo}), 1 );