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