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