diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-27 20:34:24 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-27 20:34:24 +0000 |
commit | 8e664e1028b4453f9f359cddea96cf56ea4a7c51 (patch) | |
tree | f5077a0fef175d5a1e52380032a47e33f0be4a9c /t/op/sort.t | |
parent | 24944567cd431bac90d270c4c84c69294f9784d9 (diff) | |
download | perl-8e664e1028b4453f9f359cddea96cf56ea4a7c51.tar.gz |
allow sort() reentrancy (variant of patch suggested by
Hugo van der Sanden)
p4raw-id: //depot/perl@5975
Diffstat (limited to 't/op/sort.t')
-rwxr-xr-x | t/op/sort.t | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/t/op/sort.t b/t/op/sort.t index 00b2dac1a5..8161701b0e 100755 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -5,7 +5,7 @@ BEGIN { unshift @INC, '../lib'; } use warnings; -print "1..55\n"; +print "1..57\n"; # XXX known to leak scalars { @@ -303,3 +303,21 @@ sub cxt_five { sort { test_if_scalar($a,$b); } 1,2 } @x = cxt_five(); sub cxt_six { sort test_if_scalar 1,2 } @x = cxt_six(); + +# test against a reentrancy bug +{ + package Bar; + sub compare { $a cmp $b } + sub reenter { my @force = sort compare qw/a b/ } +} +{ + my($def, $init) = (0, 0); + @b = sort { + $def = 1 if defined $Bar::a; + Bar::reenter() unless $init++; + $a <=> $b + } qw/4 3 1 2/; + print ("@b" eq '1 2 3 4' ? "ok 56\n" : "not ok 56\n"); + print "# x = '@b'\n"; + print !$def ? "ok 57\n" : "not ok 57\n"; +} |