X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fundef.t;h=04cac52fd6762650e00394e21ef0e04b2462bcee;hb=dae61315f25fcf8c7df4b4125f53b733e5e58dea;hp=f6e36a5bed43c8163e60ab349ef61d508fe7fec8;hpb=22d4bb9ccb8701e68f9243547d7e3a3c55f70908;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/undef.t b/t/op/undef.t index f6e36a5..04cac52 100755 --- a/t/op/undef.t +++ b/t/op/undef.t @@ -5,7 +5,7 @@ BEGIN { @INC = '../lib'; } -print "1..27\n"; +print "1..36\n"; print defined($a) ? "not ok 1\n" : "ok 1\n"; @@ -79,3 +79,26 @@ print $@ =~ /^Modification of a read/ ? "ok 23\n" : "not ok 23\n"; @foo = ( a => 1 ); print defined @foo ? "ok 27\n" : "not ok 27\n"; } + +{ + # [perl #17753] segfault when undef'ing unquoted string constant + eval 'undef tcp'; + print $@ =~ /^Can't modify constant item/ ? "ok 28\n" : "not ok 28\n"; +} + +# bugid 3096 +# undefing a hash may free objects with destructors that then try to +# modify the hash. To them, the hash should appear empty. + +$test = 29; +%hash = ( + key1 => bless({}, 'X'), + key2 => bless({}, 'X'), +); +undef %hash; +sub X::DESTROY { + print "not " if keys %hash; print "ok $test\n"; $test++; + print "not " if values %hash; print "ok $test\n"; $test++; + print "not " if each %hash; print "ok $test\n"; $test++; + print "not " if defined delete $hash{'key2'}; print "ok $test\n"; $test++; +}