3 # This test harness will (eventually) test the "tie" functionality
4 # without the need for a *DBM* implementation.
6 # Currently it only tests the untie warning
9 unshift @INC, "../lib";
10 $ENV{PERL5LIB} = "../lib";
14 # catch warnings into fatal errors
15 $SIG{__WARN__} = sub { die "WARNING: @_" } ;
18 @prgs = split "\n########\n", <DATA>;
19 print "1..", scalar @prgs, "\n";
22 my($prog,$expected) = split(/\nEXPECT\n/, $_);
27 $expected =~ s/\n+$//;
28 if ( $status or $results and $results !~ /^WARNING: $expected/){
29 print STDERR "STATUS: $status\n";
30 print STDERR "PROG: $prog\n";
31 print STDERR "EXPECTED:\n$expected\n";
32 print STDERR "GOT:\n$results\n";
35 print "ok ", ++$i, "\n";
40 # standard behaviour, without any extra references
47 # standard behaviour, with 1 extra reference
49 $a = tie %h, Tie::StdHash;
54 # standard behaviour, with 1 extra reference via tied
62 # standard behaviour, with 1 extra reference which is destroyed
64 $a = tie %h, Tie::StdHash;
70 # standard behaviour, with 1 extra reference via tied which is destroyed
79 # strict behaviour, without any extra references
87 # strict behaviour, with 1 extra references generating an error
90 $a = tie %h, Tie::StdHash;
93 untie attempted while 1 inner references still exist
96 # strict behaviour, with 1 extra references via tied generating an error
103 untie attempted while 1 inner references still exist
106 # strict behaviour, with 1 extra references which are destroyed
107 use warnings 'untie';
109 $a = tie %h, Tie::StdHash;
115 # strict behaviour, with extra 1 references via tied which are destroyed
116 use warnings 'untie';
118 tie %h, Tie::StdHash;
125 # strict error behaviour, with 2 extra references
126 use warnings 'untie';
128 $a = tie %h, Tie::StdHash;
132 untie attempted while 2 inner references still exist
135 # strict behaviour, check scope of strictness.
138 $A = tie %H, Tie::StdHash;
141 use warnings 'untie';
143 tie %h, Tie::StdHash;
150 # verify no leak when underlying object is selfsame tied variable
152 sub Self::TIEHASH { bless $_[1], $_[0] }
153 sub Self::DESTROY { $b = $_[0] + 0; }
157 tie %b5, 'Self', \%b5;
162 # Interaction of tie and vec
166 tie $a,Tie::StdScalar or die;