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