File: 03_refcnt.t

package info (click to toggle)
libconvert-scalar-perl 1.12-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: perl: 17; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 369 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
BEGIN { $| = 1; print "1..4\n"; }

use Convert::Scalar ':refcnt';

no bytes;

my $x = 5;

print refcnt($x) == 1 ? "" : "not ", "ok 1\n";
print refcnt($x,2) == 1 ? "" : "not ", "ok 2\n";
refcnt_inc_rv \$x;
print refcnt_rv(\$x,2) == 4 ? "" : "not ", "ok 3\n";
refcnt_inc $x;
refcnt_inc_rv \$x;
refcnt_dec $x;
print refcnt($x) == 2 ? "" : "not ", "ok 4\n";
refcnt_dec $x;