If we don't build B, we should skip all its tests.
[p5sagit/p5-mst-13.2.git] / ext / B / t / optree_specials.t
1 #!./perl
2
3 BEGIN {
4     chdir 't';
5     @INC = ('../lib', '../ext/B/t');
6     require Config;
7     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
8         print "1..0 # Skip -- Perl configured without B module\n";
9         exit 0;
10     }
11     require './test.pl';
12 }
13
14 # import checkOptree(), and %gOpts (containing test state)
15 use OptreeCheck;        # ALSO DOES @ARGV HANDLING !!!!!!
16 use Config;
17
18 plan tests => 6;
19
20 require_ok("B::Concise");
21
22 my $out = runperl(
23     switches => ["-MO=Concise,BEGIN,CHECK,INIT,END,-exec"],
24     prog => q{$a=$b && print q/foo/},
25     stderr => 1 );
26
27 #print "out:$out\n";
28
29 my $src = q[our ($beg, $chk, $init, $end) = qq{'foo'}; BEGIN { $beg++ } CHECK { $chk++ } INIT { $init++ } END { $end++ }];
30
31
32
33 checkOptree ( name      => 'BEGIN',
34               bcopts    => 'BEGIN',
35               prog      => $src,
36               expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
37 # BEGIN 1:
38 # b  <1> leavesub[1 ref] K/REFC,1 ->(end)
39 # -     <@> lineseq KP ->b
40 # 1        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->2
41 # 3        <1> require sK/1 ->4
42 # 2           <$> const[PV "strict.pm"] s/BARE ->3
43 # 4        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->5
44 # -        <@> lineseq K ->-
45 # 5           <;> nextstate(B::Concise -242 Concise.pm:304) /2 ->6
46 # a           <1> entersub[t1] KS*/TARG,2 ->b
47 # 6              <0> pushmark s ->7
48 # 7              <$> const[PV "strict"] sM ->8
49 # 8              <$> const[PV "refs"] sM ->9
50 # 9              <$> method_named[PVIV 1520340202] ->a
51 # BEGIN 2:
52 # m  <1> leavesub[1 ref] K/REFC,1 ->(end)
53 # -     <@> lineseq KP ->m
54 # c        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->d
55 # e        <1> require sK/1 ->f
56 # d           <$> const[PV "warnings.pm"] s/BARE ->e
57 # f        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->g
58 # -        <@> lineseq K ->-
59 # g           <;> nextstate(B::Concise -227 Concise.pm:327) /2 ->h
60 # l           <1> entersub[t1] KS*/TARG,2 ->m
61 # h              <0> pushmark s ->i
62 # i              <$> const[PV "warnings"] sM ->j
63 # j              <$> const[PV "qw"] sM ->k
64 # k              <$> method_named[PVIV 1520340202] ->l
65 # BEGIN 3:
66 # q  <1> leavesub[1 ref] K/REFC,1 ->(end)
67 # -     <@> lineseq KP ->q
68 # n        <;> nextstate(main 2 -e:3) v ->o
69 # p        <1> postinc[t3] sK/1 ->q
70 # -           <1> ex-rv2sv sKRM/1 ->p
71 # o              <#> gvsv[*beg] s ->p
72 EOT_EOT
73 # BEGIN 1:
74 # b  <1> leavesub[1 ref] K/REFC,1 ->(end)
75 # -     <@> lineseq KP ->b
76 # 1        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->2
77 # 3        <1> require sK/1 ->4
78 # 2           <$> const(PV "strict.pm") s/BARE ->3
79 # 4        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->5
80 # -        <@> lineseq K ->-
81 # 5           <;> nextstate(B::Concise -242 Concise.pm:304) /2 ->6
82 # a           <1> entersub[t1] KS*/TARG,2 ->b
83 # 6              <0> pushmark s ->7
84 # 7              <$> const(PV "strict") sM ->8
85 # 8              <$> const(PV "refs") sM ->9
86 # 9              <$> method_named(PVIV 1520340202) ->a
87 # BEGIN 2:
88 # m  <1> leavesub[1 ref] K/REFC,1 ->(end)
89 # -     <@> lineseq KP ->m
90 # c        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->d
91 # e        <1> require sK/1 ->f
92 # d           <$> const(PV "warnings.pm") s/BARE ->e
93 # f        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->g
94 # -        <@> lineseq K ->-
95 # g           <;> nextstate(B::Concise -227 Concise.pm:327) /2 ->h
96 # l           <1> entersub[t1] KS*/TARG,2 ->m
97 # h              <0> pushmark s ->i
98 # i              <$> const(PV "warnings") sM ->j
99 # j              <$> const(PV "qw") sM ->k
100 # k              <$> method_named(PVIV 1520340202) ->l
101 # BEGIN 3:
102 # q  <1> leavesub[1 ref] K/REFC,1 ->(end)
103 # -     <@> lineseq KP ->q
104 # n        <;> nextstate(main 2 -e:3) v ->o
105 # p        <1> postinc[t2] sK/1 ->q
106 # -           <1> ex-rv2sv sKRM/1 ->p
107 # o              <$> gvsv(*beg) s ->p
108 EONT_EONT
109
110
111 checkOptree ( name      => 'END',
112               bcopts    => 'END',
113               prog      => $src,
114               expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
115 # END 1:
116 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
117 # -     <@> lineseq KP ->4
118 # 1        <;> nextstate(main 5 -e:6) v ->2
119 # 3        <1> postinc[t3] sK/1 ->4
120 # -           <1> ex-rv2sv sKRM/1 ->3
121 # 2              <#> gvsv[*end] s ->3
122 EOT_EOT
123 # END 1:
124 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
125 # -     <@> lineseq KP ->4
126 # 1        <;> nextstate(main 5 -e:6) v ->2
127 # 3        <1> postinc[t2] sK/1 ->4
128 # -           <1> ex-rv2sv sKRM/1 ->3
129 # 2              <$> gvsv(*end) s ->3
130 EONT_EONT
131
132
133 checkOptree ( name      => 'CHECK',
134               bcopts    => 'CHECK',
135               prog      => $src,
136               expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
137 # CHECK 1:
138 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
139 # -     <@> lineseq KP ->4
140 # 1        <;> nextstate(main 3 -e:4) v ->2
141 # 3        <1> postinc[t3] sK/1 ->4
142 # -           <1> ex-rv2sv sKRM/1 ->3
143 # 2              <#> gvsv[*chk] s ->3
144 EOT_EOT
145 # CHECK 1:
146 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
147 # -     <@> lineseq KP ->4
148 # 1        <;> nextstate(main 3 -e:4) v ->2
149 # 3        <1> postinc[t2] sK/1 ->4
150 # -           <1> ex-rv2sv sKRM/1 ->3
151 # 2              <$> gvsv(*chk) s ->3
152 EONT_EONT
153
154
155 checkOptree ( name      => 'INIT',
156               bcopts    => 'INIT',
157               #todo     => 'get working',
158               prog      => $src,
159               expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
160 # INIT 1:
161 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
162 # -     <@> lineseq KP ->4
163 # 1        <;> nextstate(main 4 -e:5) v ->2
164 # 3        <1> postinc[t3] sK/1 ->4
165 # -           <1> ex-rv2sv sKRM/1 ->3
166 # 2              <#> gvsv[*init] s ->3
167 EOT_EOT
168 # INIT 1:
169 # 4  <1> leavesub[1 ref] K/REFC,1 ->(end)
170 # -     <@> lineseq KP ->4
171 # 1        <;> nextstate(main 4 -e:5) v ->2
172 # 3        <1> postinc[t2] sK/1 ->4
173 # -           <1> ex-rv2sv sKRM/1 ->3
174 # 2              <$> gvsv(*init) s ->3
175 EONT_EONT
176
177
178 checkOptree ( name      => 'all of BEGIN END INIT CHECK -exec',
179               bcopts    => [qw/ BEGIN END INIT CHECK -exec /],
180               #todo     => 'get working',
181               prog      => $src,
182               expect    => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
183 # BEGIN 1:
184 # 1  <;> nextstate(B::Concise -242 Concise.pm:304) v/2
185 # 2  <$> const[PV "strict.pm"] s/BARE
186 # 3  <1> require sK/1
187 # 4  <;> nextstate(B::Concise -242 Concise.pm:304) v/2
188 # 5  <;> nextstate(B::Concise -242 Concise.pm:304) /2
189 # 6  <0> pushmark s
190 # 7  <$> const[PV "strict"] sM
191 # 8  <$> const[PV "refs"] sM
192 # 9  <$> method_named[PVIV 1520340202] 
193 # a  <1> entersub[t1] KS*/TARG,2
194 # b  <1> leavesub[1 ref] K/REFC,1
195 # BEGIN 2:
196 # c  <;> nextstate(B::Concise -227 Concise.pm:327) v/2
197 # d  <$> const[PV "warnings.pm"] s/BARE
198 # e  <1> require sK/1
199 # f  <;> nextstate(B::Concise -227 Concise.pm:327) v/2
200 # g  <;> nextstate(B::Concise -227 Concise.pm:327) /2
201 # h  <0> pushmark s
202 # i  <$> const[PV "warnings"] sM
203 # j  <$> const[PV "qw"] sM
204 # k  <$> method_named[PVIV 1520340202] 
205 # l  <1> entersub[t1] KS*/TARG,2
206 # m  <1> leavesub[1 ref] K/REFC,1
207 # BEGIN 3:
208 # n  <;> nextstate(main 2 -e:3) v
209 # o  <#> gvsv[*beg] s
210 # p  <1> postinc[t3] sK/1
211 # q  <1> leavesub[1 ref] K/REFC,1
212 # END 1:
213 # r  <;> nextstate(main 5 -e:6) v
214 # s  <#> gvsv[*end] s
215 # t  <1> postinc[t3] sK/1
216 # u  <1> leavesub[1 ref] K/REFC,1
217 # INIT 1:
218 # v  <;> nextstate(main 4 -e:5) v
219 # w  <#> gvsv[*init] s
220 # x  <1> postinc[t3] sK/1
221 # y  <1> leavesub[1 ref] K/REFC,1
222 # CHECK 1:
223 # z  <;> nextstate(main 3 -e:4) v
224 # 10 <#> gvsv[*chk] s
225 # 11 <1> postinc[t3] sK/1
226 # 12 <1> leavesub[1 ref] K/REFC,1
227 EOT_EOT
228 # BEGIN 1:
229 # 1  <;> nextstate(B::Concise -242 Concise.pm:304) v/2
230 # 2  <$> const(PV "strict.pm") s/BARE
231 # 3  <1> require sK/1
232 # 4  <;> nextstate(B::Concise -242 Concise.pm:304) v/2
233 # 5  <;> nextstate(B::Concise -242 Concise.pm:304) /2
234 # 6  <0> pushmark s
235 # 7  <$> const(PV "strict") sM
236 # 8  <$> const(PV "refs") sM
237 # 9  <$> method_named(PVIV 1520340202) 
238 # a  <1> entersub[t1] KS*/TARG,2
239 # b  <1> leavesub[1 ref] K/REFC,1
240 # BEGIN 2:
241 # c  <;> nextstate(B::Concise -227 Concise.pm:327) v/2
242 # d  <$> const(PV "warnings.pm") s/BARE
243 # e  <1> require sK/1
244 # f  <;> nextstate(B::Concise -227 Concise.pm:327) v/2
245 # g  <;> nextstate(B::Concise -227 Concise.pm:327) /2
246 # h  <0> pushmark s
247 # i  <$> const(PV "warnings") sM
248 # j  <$> const(PV "qw") sM
249 # k  <$> method_named(PVIV 1520340202) 
250 # l  <1> entersub[t1] KS*/TARG,2
251 # m  <1> leavesub[1 ref] K/REFC,1
252 # BEGIN 3:
253 # n  <;> nextstate(main 2 -e:3) v
254 # o  <$> gvsv(*beg) s
255 # p  <1> postinc[t2] sK/1
256 # q  <1> leavesub[1 ref] K/REFC,1
257 # END 1:
258 # r  <;> nextstate(main 5 -e:6) v
259 # s  <$> gvsv(*end) s
260 # t  <1> postinc[t2] sK/1
261 # u  <1> leavesub[1 ref] K/REFC,1
262 # INIT 1:
263 # v  <;> nextstate(main 4 -e:5) v
264 # w  <$> gvsv(*init) s
265 # x  <1> postinc[t2] sK/1
266 # y  <1> leavesub[1 ref] K/REFC,1
267 # CHECK 1:
268 # z  <;> nextstate(main 3 -e:4) v
269 # 10 <$> gvsv(*chk) s
270 # 11 <1> postinc[t2] sK/1
271 # 12 <1> leavesub[1 ref] K/REFC,1
272 EONT_EONT