Debian Codegraph @

ext/XS-APItest/t/swaptwostmts.t

raw
1 use warnings;
2 use strict;
3
4 use Test::More tests => 32;
5
6 BEGIN { $^H |= 0x20000; }
7
8 my $t;
9
10 $t = "";
11 eval q{
12 use XS::APItest ();
13 $t .= "a";
14 swaptwostmts
15 $t .= "b";
16 $t .= "c";
17 $t .= "d";
18 };
19 isnt $@, "";
20
21 $t = "";
22 eval q{
23 use XS::APItest qw(swaptwostmts);
24 $t .= "a";
25 swaptwostmts
26 $t .= "b";
27 $t .= "c";
28 $t .= "d";
29 };
30 is $@, "";
31 is $t, "acbd";
32
33 $t = "";
34 eval q{
35 use XS::APItest qw(swaptwostmts);
36 $t .= "a";
37 swaptwostmts
38 if(1) { $t .= "b"; }
39 $t .= "c";
40 $t .= "d";
41 };
42 is $@, "";
43 is $t, "acbd";
44
45 $t = "";
46 eval q{
47 use XS::APItest qw(swaptwostmts);
48 $t .= "a";
49 swaptwostmts
50 $t .= "b";
51 if(1) { $t .= "c"; }
52 $t .= "d";
53 };
54 is $@, "";
55 is $t, "acbd";
56
57 $t = "";
58 eval q{
59 use XS::APItest qw(swaptwostmts);
60 $t .= "a";
61 swaptwostmts
62 $t .= "b";
63 foreach(1..3) {
64 $t .= "c";
65 swaptwostmts
66 $t .= "d";
67 $t .= "e";
68 $t .= "f";
69 }
70 $t .= "g";
71 };
72 is $@, "";
73 is $t, "acedfcedfcedfbg";
74
75 $t = "";
76 eval q{
77 use XS::APItest qw(swaptwostmts);
78 $t .= "a";
79 swaptwostmts
80 $t .= "b";
81 $t .= "c";
82 };
83 is $@, "";
84 is $t, "acb";
85
86 $t = "";
87 eval q{
88 use XS::APItest qw(swaptwostmts);
89 $t .= "a";
90 swaptwostmts
91 $t .= "b";
92 $t .= "c"
93 };
94 is $@, "";
95 is $t, "acb";
96
97 $t = "";
98 eval q{
99 use XS::APItest qw(swaptwostmts);
100 $t .= "a";
101 swaptwostmts
102 $t .= "b"
103 };
104 isnt $@, "";
105
106 $t = "";
107 eval q{
108 use XS::APItest qw(swaptwostmts);
109 $_ = $t;
110 $_ .= "a";
111 swaptwostmts
112 if(1) { $_ .= "b"; }
113 tr/a-z/A-Z/;
114 $_ .= "d";
115 $t = $_;
116 };
117 is $@, "";
118 is $t, "Abd";
119
120 $t = "";
121 eval q{
122 use XS::APItest qw(swaptwostmts);
123 sub add_to_t { $t .= $_[0]; }
124 add_to_t "a";
125 swaptwostmts
126 if(1) { add_to_t "b"; }
127 add_to_t "c";
128 add_to_t "d";
129 };
130 is $@, "";
131 is $t, "acbd";
132
133 $t = "";
134 eval q{
135 use XS::APItest qw(swaptwostmts);
136 { $t .= "a"; }
137 swaptwostmts
138 if(1) { { $t .= "b"; } }
139 { $t .= "c"; }
140 { $t .= "d"; }
141 };
142 is $@, "";
143 is $t, "acbd";
144
145 $t = "";
146 eval q{
147 use XS::APItest qw(swaptwostmts);
148 no warnings "void";
149 { $t .= "a"; }
150 swaptwostmts
151 if(1) { { $t .= "b"; } }
152 {};
153 { $t .= "d"; }
154 };
155 is $@, "";
156 is $t, "abd";
157
158 $t = "";
159 eval q{
160 use XS::APItest qw(swaptwostmts);
161 no warnings "void";
162 { $t .= "a"; }
163 swaptwostmts
164 if(1) { { $t .= "b"; } }
165 [];
166 { $t .= "d"; }
167 };
168 is $@, "";
169 is $t, "abd";
170
171 $t = "";
172 eval q{
173 use XS::APItest qw(swaptwostmts);
174 no warnings "void";
175 "@{[ $t .= 'a' ]}";
176 swaptwostmts
177 if(1) { "@{[ $t .= 'b' ]}"; }
178 "@{[ $t .= 'c' ]}";
179 "@{[ $t .= 'd' ]}";
180 };
181 is $@, "";
182 is $t, "acbd";
183
184 $t = "";
185 eval q{
186 use XS::APItest qw(swaptwostmts);
187 $t .= "a";
188 swaptwostmts
189 x:
190 $t .= "b";
191 z:
192 $t .= "c";
193 $t .= "d";
194 };
195 is $@, "";
196 is $t, "acbd";
197
198 $t = "";
199 eval q{
200 use XS::APItest qw(swaptwostmts);
201 $t .= "a";
202 goto x;
203 $t .= "b";
204 swaptwostmts
205 x:
206 $t .= "c";
207 $t .= "d";
208 $t .= "e";
209 };
210 is $@, "";
211 is $t, "ace";
212
213 $t = "";
214 eval q{
215 use XS::APItest qw(swaptwostmts);
216 $t .= "a";
217 goto x;
218 $t .= "b";
219 swaptwostmts
220 $t .= "c";
221 x:
222 $t .= "d";
223 $t .= "e";
224 };
225 is $@, "";
226 is $t, "adce";
227
228 1;