X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fwantarray.t;h=350270d11c28271acd528cbd91e7157e58923f17;hb=dae61315f25fcf8c7df4b4125f53b733e5e58dea;hp=4b6f37cf0fa4630a4bb8ee1271cb9482fa0e673d;hpb=4b19af017623bfa3bb72bb164598a517f586e0d3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/wantarray.t b/t/op/wantarray.t index 4b6f37c..350270d 100755 --- a/t/op/wantarray.t +++ b/t/op/wantarray.t @@ -1,6 +1,6 @@ #!./perl -print "1..7\n"; +print "1..12\n"; sub context { my ( $cona, $testnum ) = @_; my $conb = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V'; @@ -17,4 +17,28 @@ scalar context('S',4); $a = scalar context('S',5); ($a) = context('A',6); ($a) = scalar context('S',7); + +{ + # [ID 20020626.011] incorrect wantarray optimisation + sub simple { wantarray ? 1 : 2 } + sub inline { + my $a = wantarray ? simple() : simple(); + $a; + } + my @b = inline(); + my $c = inline(); + print +(@b == 1 && "@b" eq "2") ? "ok 8\n" : "not ok 8\t# <@b>\n"; + print +($c == 2) ? "ok 9\n" : "not ok 9\t# <$c>\n"; +} + +my $qcontext = q{ + $q = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V'; +}; +eval $qcontext; +print $q eq 'V' ? "ok 10\n" : "not ok 10\n"; +$a = eval $qcontext; +print $q eq 'S' ? "ok 11\n" : "not ok 11\n"; +@a = eval $qcontext; +print $q eq 'A' ? "ok 12\n" : "not ok 12\n"; + 1;