swaplabel.t revision 1.1.1.1
1use warnings; 2use strict; 3 4use Test::More tests => 56; 5 6BEGIN { $^H |= 0x20000; } 7 8my $t; 9 10$t = ""; 11eval q{ 12 use XS::APItest qw(swaplabel); 13 $t .= "a"; 14 $t .= "b"; 15 swaplabel $t .= "c"; 16 swaplabel $t .= "d"; 17 $t .= "e"; 18}; 19is $@, ""; 20is $t, "abcde"; 21 22$t = ""; 23eval q{ 24 use XS::APItest qw(swaplabel); 25 $t .= "a"; 26 Lb: $t .= "b"; 27 swaplabel $t .= "c"; Lc: 28 swaplabel $t .= "d"; Ld: 29 Le: $t .= "e"; 30}; 31is $@, ""; 32is $t, "abcde"; 33 34$t = ""; 35eval q{ 36 use XS::APItest qw(swaplabel); 37 $t .= "a"; 38 goto Lb; 39 Lb: $t .= "b"; 40 swaplabel $t .= "c"; Lc: 41 swaplabel $t .= "d"; Ld: 42 Le: $t .= "e"; 43}; 44is $@, ""; 45is $t, "abcde"; 46 47$t = ""; 48eval q{ 49 use XS::APItest qw(swaplabel); 50 $t .= "a"; 51 goto Lc; 52 Lb: $t .= "b"; 53 swaplabel $t .= "c"; Lc: 54 swaplabel $t .= "d"; Ld: 55 Le: $t .= "e"; 56}; 57is $@, ""; 58is $t, "acde"; 59 60$t = ""; 61eval q{ 62 use XS::APItest qw(swaplabel); 63 $t .= "a"; 64 goto Ld; 65 Lb: $t .= "b"; 66 swaplabel $t .= "c"; Lc: 67 swaplabel $t .= "d"; Ld: 68 Le: $t .= "e"; 69}; 70is $@, ""; 71is $t, "ade"; 72 73$t = ""; 74eval q{ 75 use XS::APItest qw(swaplabel); 76 $t .= "a"; 77 goto Le; 78 Lb: $t .= "b"; 79 swaplabel $t .= "c"; Lc: 80 swaplabel $t .= "d"; Ld: 81 Le: $t .= "e"; 82}; 83is $@, ""; 84is $t, "ae"; 85 86$t = ""; 87eval q{ 88 use XS::APItest qw(swaplabel); 89 $t .= "a"; 90 swaplabel $t .= "b"; y: 91 $t .= "c"; 92}; 93isnt $@, ""; 94is $t, ""; 95 96$t = ""; 97eval q{ 98 use XS::APItest qw(swaplabel); 99 if(1) { $t .= "a"; } 100 if(1) { $t .= "b"; } 101 swaplabel if(1) { $t .= "c"; } 102 swaplabel if(1) { $t .= "d"; } 103 if(1) { $t .= "e"; } 104}; 105is $@, ""; 106is $t, "abcde"; 107 108$t = ""; 109eval q{ 110 use XS::APItest qw(swaplabel); 111 if(1) { $t .= "a"; } 112 Lb: if(1) { $t .= "b"; } 113 swaplabel if(1) { $t .= "c"; } Lc: 114 swaplabel if(1) { $t .= "d"; } Ld: 115 Le: if(1) { $t .= "e"; } 116}; 117is $@, ""; 118is $t, "abcde"; 119 120$t = ""; 121eval q{ 122 use XS::APItest qw(swaplabel); 123 if(1) { $t .= "a"; } 124 goto Lb; 125 Lb: if(1) { $t .= "b"; } 126 swaplabel if(1) { $t .= "c"; } Lc: 127 swaplabel if(1) { $t .= "d"; } Ld: 128 Le: if(1) { $t .= "e"; } 129}; 130is $@, ""; 131is $t, "abcde"; 132 133$t = ""; 134eval q{ 135 use XS::APItest qw(swaplabel); 136 if(1) { $t .= "a"; } 137 goto Lc; 138 Lb: if(1) { $t .= "b"; } 139 swaplabel if(1) { $t .= "c"; } Lc: 140 swaplabel if(1) { $t .= "d"; } Ld: 141 Le: if(1) { $t .= "e"; } 142}; 143is $@, ""; 144is $t, "acde"; 145 146$t = ""; 147eval q{ 148 use XS::APItest qw(swaplabel); 149 if(1) { $t .= "a"; } 150 goto Ld; 151 Lb: if(1) { $t .= "b"; } 152 swaplabel if(1) { $t .= "c"; } Lc: 153 swaplabel if(1) { $t .= "d"; } Ld: 154 Le: if(1) { $t .= "e"; } 155}; 156is $@, ""; 157is $t, "ade"; 158 159$t = ""; 160eval q{ 161 use XS::APItest qw(swaplabel); 162 if(1) { $t .= "a"; } 163 goto Le; 164 Lb: if(1) { $t .= "b"; } 165 swaplabel if(1) { $t .= "c"; } Lc: 166 swaplabel if(1) { $t .= "d"; } Ld: 167 Le: if(1) { $t .= "e"; } 168}; 169is $@, ""; 170is $t, "ae"; 171 172$t = ""; 173eval q{ 174 use XS::APItest qw(swaplabel); 175 if(1) { $t .= "a"; } 176 swaplabel if(1) { $t .= "b"; } y: 177 if(1) { $t .= "c"; } 178}; 179isnt $@, ""; 180is $t, ""; 181 182{ 183 use utf8; 184 use open qw( :utf8 :std ); 185 186 $t = ""; 187 eval q{ 188 use XS::APItest qw(swaplabel); 189 $t .= "���"; 190 $t .= "���"; 191 swaplabel $t .= "���"; 192 swaplabel $t .= "���"; 193 $t .= "���"; 194 }; 195 is $@, ""; 196 is $t, "���������������"; 197 198 $t = ""; 199 eval q{ 200 use XS::APItest qw(swaplabel); 201 $t .= "���"; 202 L���: $t .= "���"; 203 swaplabel $t .= "���"; L���: 204 swaplabel $t .= "���"; L���: 205 L���: $t .= "���"; 206 }; 207 is $@, ""; 208 is $t, "���������������"; 209 210 $t = ""; 211 eval q{ 212 use XS::APItest qw(swaplabel); 213 $t .= "���"; 214 goto L���; 215 L���: $t .= "���"; 216 swaplabel $t .= "���"; L���: 217 swaplabel $t .= "���"; L���: 218 L���: $t .= "���"; 219 }; 220 is $@, ""; 221 is $t, "���������������"; 222 223 $t = ""; 224 eval q{ 225 use XS::APItest qw(swaplabel); 226 $t .= "���"; 227 goto L���; 228 L���: $t .= "���"; 229 swaplabel $t .= "���"; L���: 230 swaplabel $t .= "���"; L���: 231 L���: $t .= "���"; 232 }; 233 is $@, ""; 234 is $t, "������������"; 235 236 $t = ""; 237 eval q{ 238 use XS::APItest qw(swaplabel); 239 $t .= "���"; 240 goto L���; 241 L���: $t .= "���"; 242 swaplabel $t .= "���"; L���: 243 swaplabel $t .= "���"; L���: 244 L���: $t .= "���"; 245 }; 246 is $@, ""; 247 is $t, "���������"; 248 249 $t = ""; 250 eval q{ 251 use XS::APItest qw(swaplabel); 252 $t .= "���"; 253 goto L���; 254 L���: $t .= "���"; 255 swaplabel $t .= "���"; L���: 256 swaplabel $t .= "���"; L���: 257 L���: $t .= "���"; 258 }; 259 is $@, ""; 260 is $t, "������"; 261 262 $t = ""; 263 eval q{ 264 use XS::APItest qw(swaplabel); 265 $t .= "���"; 266 swaplabel $t .= "���"; y: 267 $t .= "���"; 268 }; 269 isnt $@, ""; 270 is $t, ""; 271 272 $t = ""; 273 eval q{ 274 use XS::APItest qw(swaplabel); 275 if(1) { $t .= "���"; } 276 if(1) { $t .= "���"; } 277 swaplabel if(1) { $t .= "���"; } 278 swaplabel if(1) { $t .= "���"; } 279 if(1) { $t .= "���"; } 280 }; 281 is $@, ""; 282 is $t, "���������������"; 283 284 $t = ""; 285 eval q{ 286 use XS::APItest qw(swaplabel); 287 if(1) { $t .= "���"; } 288 L���: if(1) { $t .= "���"; } 289 swaplabel if(1) { $t .= "���"; } L���: 290 swaplabel if(1) { $t .= "���"; } L���: 291 L���: if(1) { $t .= "���"; } 292 }; 293 is $@, ""; 294 is $t, "���������������"; 295 296 $t = ""; 297 eval q{ 298 use XS::APItest qw(swaplabel); 299 if(1) { $t .= "���"; } 300 goto L���; 301 L���: if(1) { $t .= "���"; } 302 swaplabel if(1) { $t .= "���"; } L���: 303 swaplabel if(1) { $t .= "���"; } L���: 304 L���: if(1) { $t .= "���"; } 305 }; 306 is $@, ""; 307 is $t, "���������������"; 308 309 $t = ""; 310 eval q{ 311 use XS::APItest qw(swaplabel); 312 if(1) { $t .= "���"; } 313 goto L���; 314 L���: if(1) { $t .= "���"; } 315 swaplabel if(1) { $t .= "���"; } L���: 316 swaplabel if(1) { $t .= "���"; } L���: 317 L���: if(1) { $t .= "���"; } 318 }; 319 is $@, ""; 320 is $t, "������������"; 321 322 $t = ""; 323 eval q{ 324 use XS::APItest qw(swaplabel); 325 if(1) { $t .= "���"; } 326 goto L���; 327 L���: if(1) { $t .= "���"; } 328 swaplabel if(1) { $t .= "���"; } L���: 329 swaplabel if(1) { $t .= "���"; } L���: 330 L���: if(1) { $t .= "���"; } 331 }; 332 is $@, ""; 333 is $t, "���������"; 334 335 $t = ""; 336 eval q{ 337 use XS::APItest qw(swaplabel); 338 if(1) { $t .= "���"; } 339 goto L���; 340 L���: if(1) { $t .= "���"; } 341 swaplabel if(1) { $t .= "���"; } L���: 342 swaplabel if(1) { $t .= "���"; } L���: 343 L���: if(1) { $t .= "���"; } 344 }; 345 is $@, ""; 346 is $t, "������"; 347 348 $t = ""; 349 eval q{ 350 use XS::APItest qw(swaplabel); 351 if(1) { $t .= "���"; } 352 swaplabel if(1) { $t .= "���"; } y: 353 if(1) { $t .= "���"; } 354 }; 355 isnt $@, ""; 356 is $t, ""; 357} 358 3591; 360