Commit | Line | Data |
---|---|---|
1d0ef875 | 1 | #!./perl |
2 | ||
dab34d0f | 3 | BEGIN { |
4 | chdir 't' if -d 't'; | |
5 | @INC = '../lib'; | |
6 | require './test.pl'; | |
7 | } | |
8 | ||
9 | use strict; | |
10 | ||
11 | plan 13; | |
12 | ||
1d0ef875 | 13 | sub context { |
dab34d0f | 14 | local $::Level = $::Level + 1; |
1d0ef875 | 15 | my ( $cona, $testnum ) = @_; |
16 | my $conb = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V'; | |
dab34d0f | 17 | is $cona, $conb; |
1d0ef875 | 18 | } |
19 | ||
dab34d0f | 20 | context('V'); |
21 | my $a = context('S'); | |
22 | my @a = context('A'); | |
23 | scalar context('S'); | |
24 | $a = scalar context('S'); | |
25 | ($a) = context('A'); | |
26 | ($a) = scalar context('S'); | |
d2ccd3cb | 27 | |
28 | { | |
29 | # [ID 20020626.011] incorrect wantarray optimisation | |
30 | sub simple { wantarray ? 1 : 2 } | |
31 | sub inline { | |
32 | my $a = wantarray ? simple() : simple(); | |
33 | $a; | |
34 | } | |
35 | my @b = inline(); | |
36 | my $c = inline(); | |
dab34d0f | 37 | is @b, 1; |
38 | is "@b", "2"; | |
39 | is $c, 2; | |
d2ccd3cb | 40 | } |
41 | ||
dab34d0f | 42 | my $q; |
43 | ||
cc37eb0b | 44 | my $qcontext = q{ |
45 | $q = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V'; | |
46 | }; | |
47 | eval $qcontext; | |
dab34d0f | 48 | is $q, 'V'; |
cc37eb0b | 49 | $a = eval $qcontext; |
dab34d0f | 50 | is $q, 'S'; |
cc37eb0b | 51 | @a = eval $qcontext; |
dab34d0f | 52 | is $q, 'A'; |
cc37eb0b | 53 | |
1d0ef875 | 54 | 1; |