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