This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document that the -Ci, -Co, and -CD options have file scope
[perl5.git] / ext / B / t / optree_misc.t
CommitLineData
c60fdceb
SM
1#!perl
2
3BEGIN {
74517a3a 4 unshift @INC, 't';
c60fdceb
SM
5 require Config;
6 if (($Config::Config{'extensions'} !~ /\bB\b/) ){
7 print "1..0 # Skip -- Perl configured without B module\n";
8 exit 0;
9 }
10}
11use OptreeCheck;
12use Config;
98517ccb 13plan tests => 3;
c60fdceb
SM
14
15SKIP: {
16skip "no perlio in this build", 1 unless $Config::Config{useperlio};
17
18# The regression this is testing is that the first aelemfast, derived
19# from a lexical array, is supposed to be a BASEOP "<0>", while the
20# second, from a global, is an SVOP "<$>" or a PADOP "<#>" depending
21# on threading. In buggy versions, both showed up as SVOPs/PADOPs. See
22# B.xs:cc_opclass() for the relevant code.
23
24checkOptree ( name => 'OP_AELEMFAST opclass',
25 code => sub { my @x; our @y; $x[0] + $y[0]},
be2b1c74 26 strip_open_hints => 1,
c60fdceb
SM
27 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
28# a <1> leavesub[1 ref] K/REFC,1 ->(end)
29# - <@> lineseq KP ->a
be2b1c74 30# 1 <;> nextstate(main 634 optree_misc.t:25) v:>,<,% ->2
c60fdceb 31# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
be2b1c74 32# 3 <;> nextstate(main 635 optree_misc.t:25) v:>,<,% ->4
c60fdceb
SM
33# 5 <1> rv2av[t4] vK/OURINTR,1 ->6
34# 4 <#> gv[*y] s ->5
be2b1c74 35# 6 <;> nextstate(main 636 optree_misc.t:25) v:>,<,%,{ ->7
c60fdceb
SM
36# 9 <2> add[t6] sK/2 ->a
37# - <1> ex-aelem sK/2 ->8
38# 7 <0> aelemfast[@x:634,636] sR* ->8
39# - <0> ex-const s ->-
40# - <1> ex-aelem sK/2 ->9
41# - <1> ex-rv2av sKR/1 ->-
42# 8 <#> aelemfast[*y] s ->9
43# - <0> ex-const s ->-
44EOT_EOT
45# a <1> leavesub[1 ref] K/REFC,1 ->(end)
46# - <@> lineseq KP ->a
be2b1c74 47# 1 <;> nextstate(main 634 optree_misc.t:27) v:>,<,% ->2
c60fdceb 48# 2 <0> padav[@x:634,636] vM/LVINTRO ->3
be2b1c74 49# 3 <;> nextstate(main 635 optree_misc.t:27) v:>,<,% ->4
c60fdceb
SM
50# 5 <1> rv2av[t3] vK/OURINTR,1 ->6
51# 4 <$> gv(*y) s ->5
be2b1c74 52# 6 <;> nextstate(main 636 optree_misc.t:27) v:>,<,%,{ ->7
c60fdceb
SM
53# 9 <2> add[t4] sK/2 ->a
54# - <1> ex-aelem sK/2 ->8
55# 7 <0> aelemfast[@x:634,636] sR* ->8
56# - <0> ex-const s ->-
57# - <1> ex-aelem sK/2 ->9
58# - <1> ex-rv2av sKR/1 ->-
59# 8 <$> aelemfast(*y) s ->9
60# - <0> ex-const s ->-
61EONT_EONT
62
63
64} #skip
65
50786ba8
NC
66my $t = <<'EOT_EOT';
67# 8 <@> leave[1 ref] vKP/REFC ->(end)
68# 1 <0> enter ->2
2acfb4e0 69# 2 <;> nextstate(main 1 -e:1) v:>,<,%,{ ->3
50786ba8
NC
70# 7 <2> sassign vKS/2 ->8
71# 5 <@> index[t2] sK/2 ->6
72# - <0> ex-pushmark s ->3
73# 3 <$> const[PV "foo"] s ->4
74# 4 <$> const[GV "foo"] s ->5
75# - <1> ex-rv2sv sKRM*/1 ->7
76# 6 <#> gvsv[*_] s ->7
77EOT_EOT
78my $nt = <<'EONT_EONT';
79# 8 <@> leave[1 ref] vKP/REFC ->(end)
80# 1 <0> enter ->2
2acfb4e0 81# 2 <;> nextstate(main 1 -e:1) v:>,<,%,{ ->3
50786ba8
NC
82# 7 <2> sassign vKS/2 ->8
83# 5 <@> index[t1] sK/2 ->6
84# - <0> ex-pushmark s ->3
85# 3 <$> const(PV "foo") s ->4
86# 4 <$> const(GV "foo") s ->5
87# - <1> ex-rv2sv sKRM*/1 ->7
88# 6 <$> gvsv(*_) s ->7
89EONT_EONT
90
91if ($] < 5.009) {
92 $t =~ s/GV /BM /;
93 $nt =~ s/GV /BM /;
94}
95
96checkOptree ( name => 'index and PVBM',
22aebd37 97 prog => '$_ = index q(foo), q(foo)',
2acfb4e0 98 strip_open_hints => 1,
50786ba8
NC
99 expect => $t, expect_nt => $nt);
100
98517ccb
NC
101checkOptree ( name => 'PMOP children',
102 code => sub { $foo =~ s/(a)/$1/ },
103 strip_open_hints => 1,
104 expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
105# 6 <1> leavesub[1 ref] K/REFC,1 ->(end)
106# - <@> lineseq KP ->6
107# 1 <;> nextstate(main 1 -e:1) v:{ ->2
108# 3 </> subst(/"(a)"/ replstart->4) KS ->6
109# - <1> ex-rv2sv sKRM/1 ->3
110# 2 <#> gvsv[*foo] s ->3
111# 5 <|> substcont(other->3) sK/1 ->(end)
112# - <1> ex-rv2sv sK/1 ->5
113# 4 <#> gvsv[*1] s ->5
114EOT_EOT
115# 6 <1> leavesub[1 ref] K/REFC,1 ->(end)
116# - <@> lineseq KP ->6
117# 1 <;> nextstate(main 1 -e:1) v:{ ->2
118# 3 </> subst(/"(a)"/ replstart->4) KS ->6
119# - <1> ex-rv2sv sKRM/1 ->3
120# 2 <$> gvsv(*foo) s ->3
121# 5 <|> substcont(other->3) sK/1 ->(end)
122# - <1> ex-rv2sv sK/1 ->5
123# 4 <$> gvsv(*1) s ->5
124EONT_EONT
c60fdceb 125
98517ccb 126__END__