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
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, without any extra references
49 {package Tie::HashUntie;
50 use base 'Tie::StdHash';
56 tie %h, Tie::HashUntie;
62 # standard behaviour, with 1 extra reference
64 $a = tie %h, Tie::StdHash;
69 # standard behaviour, with 1 extra reference via tied
77 # standard behaviour, with 1 extra reference which is destroyed
79 $a = tie %h, Tie::StdHash;
85 # standard behaviour, with 1 extra reference via tied which is destroyed
94 # strict behaviour, without any extra references
102 # strict behaviour, with 1 extra references generating an error
103 use warnings 'untie';
105 $a = tie %h, Tie::StdHash;
108 untie attempted while 1 inner references still exist
111 # strict behaviour, with 1 extra references via tied generating an error
112 use warnings 'untie';
114 tie %h, Tie::StdHash;
118 untie attempted while 1 inner references still exist
121 # strict behaviour, with 1 extra references which are destroyed
122 use warnings 'untie';
124 $a = tie %h, Tie::StdHash;
130 # strict behaviour, with extra 1 references via tied which are destroyed
131 use warnings 'untie';
133 tie %h, Tie::StdHash;
140 # strict error behaviour, with 2 extra references
141 use warnings 'untie';
143 $a = tie %h, Tie::StdHash;
147 untie attempted while 2 inner references still exist
150 # strict behaviour, check scope of strictness.
153 $A = tie %H, Tie::StdHash;
156 use warnings 'untie';
158 tie %h, Tie::StdHash;
165 # verify no leak when underlying object is selfsame tied variable
167 sub Self::TIEHASH { bless $_[1], $_[0] }
168 sub Self::DESTROY { $b = $_[0] + 0; }
172 tie %b5, 'Self', \%b5;
177 # Interaction of tie and vec
181 tie $a,Tie::StdScalar or die;