| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | use Test::More tests => 3; |
| 7 | use Test::Fatal; |
| 8 | |
| 9 | use Devel::Refcount qw( assert_oneref ); |
| 10 | |
| 11 | my $anon = []; |
| 12 | |
| 13 | ok( !exception { assert_oneref $anon }, |
| 14 | 'assert_oneref on one-reference anon array' ); |
| 15 | |
| 16 | my $otherref = $anon; |
| 17 | |
| 18 | like( exception { assert_oneref $anon }, |
| 19 | qr/^Expected ARRAY\(0x[[:xdigit:]]+\) to have only one reference, found 2 at /, |
| 20 | 'assert_oneref on two-reference anon array' ); |
| 21 | |
| 22 | my %hash = ( element => [] ); |
| 23 | |
| 24 | ok( !exception { assert_oneref delete $hash{element} }, |
| 25 | 'assert_oneref on deleted hash element' ); |