| 1 | # -------------------------------------------------- in-module-0 |
| 2 | global_var = 3 |
| 3 | def x(): |
| 4 | foo = 3.1 |
| 5 | #? 11 text {'new_name': 'bar'} |
| 6 | x = int(foo + 1 + global_var) |
| 7 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 8 | global_var = 3 |
| 9 | def bar(foo): |
| 10 | return int(foo + 1 + global_var) |
| 11 | |
| 12 | |
| 13 | def x(): |
| 14 | foo = 3.1 |
| 15 | #? 11 text {'new_name': 'bar'} |
| 16 | x = bar(foo) |
| 17 | # -------------------------------------------------- in-module-1 |
| 18 | glob = 3 |
| 19 | #? 11 text {'new_name': 'a'} |
| 20 | test(100, (glob.a + b, c) + 1) |
| 21 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 22 | glob = 3 |
| 23 | #? 11 text {'new_name': 'a'} |
| 24 | def a(b): |
| 25 | return glob.a + b |
| 26 | |
| 27 | |
| 28 | test(100, (a(b), c) + 1) |
| 29 | # -------------------------------------------------- in-module-2 |
| 30 | #? 0 text {'new_name': 'ab'} |
| 31 | 100 + 1 * 2 |
| 32 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 33 | #? 0 text {'new_name': 'ab'} |
| 34 | def ab(): |
| 35 | return 100 + 1 * 2 |
| 36 | |
| 37 | |
| 38 | ab() |
| 39 | # -------------------------------------------------- in-function-1 |
| 40 | def f(x): |
| 41 | #? 11 text {'new_name': 'ab'} |
| 42 | return x + 1 * 2 |
| 43 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 44 | def ab(x): |
| 45 | return x + 1 * 2 |
| 46 | |
| 47 | |
| 48 | def f(x): |
| 49 | #? 11 text {'new_name': 'ab'} |
| 50 | return ab(x) |
| 51 | # -------------------------------------------------- in-function-with-dec |
| 52 | @classmethod |
| 53 | def f(x): |
| 54 | #? 11 text {'new_name': 'ab'} |
| 55 | return x + 1 * 2 |
| 56 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 57 | def ab(x): |
| 58 | return x + 1 * 2 |
| 59 | |
| 60 | |
| 61 | @classmethod |
| 62 | def f(x): |
| 63 | #? 11 text {'new_name': 'ab'} |
| 64 | return ab(x) |
| 65 | # -------------------------------------------------- in-method-1 |
| 66 | class X: |
| 67 | def z(self): pass |
| 68 | |
| 69 | def f(x, b): |
| 70 | #? 11 text {'new_name': 'ab'} |
| 71 | return x + b * 2 |
| 72 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 73 | class X: |
| 74 | def z(self): pass |
| 75 | |
| 76 | def ab(x, b): |
| 77 | return x + b * 2 |
| 78 | |
| 79 | def f(x, b): |
| 80 | #? 11 text {'new_name': 'ab'} |
| 81 | return x.ab(b) |
| 82 | # -------------------------------------------------- in-method-2 |
| 83 | glob1 = 1 |
| 84 | class X: |
| 85 | def g(self): pass |
| 86 | |
| 87 | def f(self, b, c): |
| 88 | #? 11 text {'new_name': 'ab'} |
| 89 | return self.g() or self.f(b) ^ glob1 & b |
| 90 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 91 | glob1 = 1 |
| 92 | class X: |
| 93 | def g(self): pass |
| 94 | |
| 95 | def ab(self, b): |
| 96 | return self.g() or self.f(b) ^ glob1 & b |
| 97 | |
| 98 | def f(self, b, c): |
| 99 | #? 11 text {'new_name': 'ab'} |
| 100 | return self.ab(b) |
| 101 | # -------------------------------------------------- in-method-order |
| 102 | class X: |
| 103 | def f(self, b, c): |
| 104 | #? 18 text {'new_name': 'b'} |
| 105 | return b | self.a |
| 106 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 107 | class X: |
| 108 | def b(self, b): |
| 109 | return b | self.a |
| 110 | |
| 111 | def f(self, b, c): |
| 112 | #? 18 text {'new_name': 'b'} |
| 113 | return self.b(b) |
| 114 | # -------------------------------------------------- in-classmethod-1 |
| 115 | class X: |
| 116 | @classmethod |
| 117 | def f(x): |
| 118 | #? 16 text {'new_name': 'ab'} |
| 119 | return 25 |
| 120 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 121 | class X: |
| 122 | @classmethod |
| 123 | def ab(x): |
| 124 | return 25 |
| 125 | |
| 126 | @classmethod |
| 127 | def f(x): |
| 128 | #? 16 text {'new_name': 'ab'} |
| 129 | return x.ab() |
| 130 | # -------------------------------------------------- in-staticmethod-1 |
| 131 | class X(int): |
| 132 | @staticmethod |
| 133 | def f(x): |
| 134 | #? 16 text {'new_name': 'ab'} |
| 135 | return 25 | 3 |
| 136 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 137 | def ab(): |
| 138 | return 25 | 3 |
| 139 | |
| 140 | class X(int): |
| 141 | @staticmethod |
| 142 | def f(x): |
| 143 | #? 16 text {'new_name': 'ab'} |
| 144 | return ab() |
| 145 | # -------------------------------------------------- in-class-1 |
| 146 | class Ya(): |
| 147 | a = 3 |
| 148 | #? 11 text {'new_name': 'f'} |
| 149 | c = a + 2 |
| 150 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 151 | def f(a): |
| 152 | return a + 2 |
| 153 | |
| 154 | |
| 155 | class Ya(): |
| 156 | a = 3 |
| 157 | #? 11 text {'new_name': 'f'} |
| 158 | c = f(a) |
| 159 | # -------------------------------------------------- in-closure |
| 160 | def x(z): |
| 161 | def y(x): |
| 162 | #? 15 text {'new_name': 'f'} |
| 163 | return -x * z |
| 164 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 165 | def f(x, z): |
| 166 | return -x * z |
| 167 | |
| 168 | |
| 169 | def x(z): |
| 170 | def y(x): |
| 171 | #? 15 text {'new_name': 'f'} |
| 172 | return f(x, z) |
| 173 | # -------------------------------------------------- with-range-1 |
| 174 | #? 0 text {'new_name': 'a', 'until_line': 4} |
| 175 | v1 = 3 |
| 176 | v2 = 2 |
| 177 | x = test(v1 + v2 * v3) |
| 178 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 179 | #? 0 text {'new_name': 'a', 'until_line': 4} |
| 180 | def a(test, v3): |
| 181 | v1 = 3 |
| 182 | v2 = 2 |
| 183 | x = test(v1 + v2 * v3) |
| 184 | return x |
| 185 | |
| 186 | |
| 187 | x = a(test, v3) |
| 188 | # -------------------------------------------------- with-range-2 |
| 189 | #? 2 text {'new_name': 'a', 'until_line': 6, 'until_column': 4} |
| 190 | #foo |
| 191 | v1 = 3 |
| 192 | v2 = 2 |
| 193 | x, y = test(v1 + v2 * v3) |
| 194 | #raaaa |
| 195 | y |
| 196 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 197 | #? 2 text {'new_name': 'a', 'until_line': 6, 'until_column': 4} |
| 198 | def a(test, v3): |
| 199 | #foo |
| 200 | v1 = 3 |
| 201 | v2 = 2 |
| 202 | x, y = test(v1 + v2 * v3) |
| 203 | #raaaa |
| 204 | return y |
| 205 | |
| 206 | |
| 207 | y = a(test, v3) |
| 208 | y |
| 209 | # -------------------------------------------------- with-range-3 |
| 210 | #foo |
| 211 | #? 2 text {'new_name': 'a', 'until_line': 5, 'until_column': 4} |
| 212 | v1 = 3 |
| 213 | v2 = 2 |
| 214 | x, y = test(v1 + v2 * v3) |
| 215 | #raaaa |
| 216 | y |
| 217 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 218 | #foo |
| 219 | #? 2 text {'new_name': 'a', 'until_line': 5, 'until_column': 4} |
| 220 | def a(test, v3): |
| 221 | v1 = 3 |
| 222 | v2 = 2 |
| 223 | x, y = test(v1 + v2 * v3) |
| 224 | return y |
| 225 | |
| 226 | |
| 227 | y = a(test, v3) |
| 228 | #raaaa |
| 229 | y |
| 230 | # -------------------------------------------------- with-range-func-1 |
| 231 | import os |
| 232 | # comment1 |
| 233 | @dec |
| 234 | # comment2 |
| 235 | def x(v1): |
| 236 | #foo |
| 237 | #? 2 text {'new_name': 'a', 'until_line': 9, 'until_column': 5} |
| 238 | v2 = 2 |
| 239 | if 1: |
| 240 | x, y = os.listdir(v1 + v2 * v3) |
| 241 | #bar |
| 242 | return x, y |
| 243 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 244 | import os |
| 245 | # comment1 |
| 246 | def a(v1, v3): |
| 247 | v2 = 2 |
| 248 | if 1: |
| 249 | x, y = os.listdir(v1 + v2 * v3) |
| 250 | return x, y |
| 251 | |
| 252 | |
| 253 | @dec |
| 254 | # comment2 |
| 255 | def x(v1): |
| 256 | #foo |
| 257 | #? 2 text {'new_name': 'a', 'until_line': 9, 'until_column': 5} |
| 258 | x, y = a(v1, v3) |
| 259 | #bar |
| 260 | return x, y |
| 261 | # -------------------------------------------------- with-range-func-2 |
| 262 | import os |
| 263 | # comment1 |
| 264 | # comment2 |
| 265 | def x(v1): |
| 266 | #? 2 text {'new_name': 'a', 'until_line': 10, 'until_column': 0} |
| 267 | #foo |
| 268 | v2 = 2 |
| 269 | if 1: |
| 270 | x, y = os.listdir(v1 + v2 * v3) |
| 271 | #bar |
| 272 | return y |
| 273 | x |
| 274 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 275 | import os |
| 276 | # comment1 |
| 277 | # comment2 |
| 278 | def a(v1, v3): |
| 279 | #foo |
| 280 | v2 = 2 |
| 281 | if 1: |
| 282 | x, y = os.listdir(v1 + v2 * v3) |
| 283 | #bar |
| 284 | return y |
| 285 | |
| 286 | |
| 287 | def x(v1): |
| 288 | #? 2 text {'new_name': 'a', 'until_line': 10, 'until_column': 0} |
| 289 | y = a(v1, v3) |
| 290 | return y |
| 291 | x |
| 292 | # -------------------------------------------------- with-range-func-3 |
| 293 | def x(v1): |
| 294 | #? 2 text {'new_name': 'func', 'until_line': 6, 'until_column': 4} |
| 295 | #foo |
| 296 | v2 = 2 |
| 297 | x = v1 * 2 |
| 298 | y = 3 |
| 299 | #bar |
| 300 | return x |
| 301 | x |
| 302 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 303 | def func(v1): |
| 304 | #foo |
| 305 | v2 = 2 |
| 306 | x = v1 * 2 |
| 307 | return x |
| 308 | |
| 309 | |
| 310 | def x(v1): |
| 311 | #? 2 text {'new_name': 'func', 'until_line': 6, 'until_column': 4} |
| 312 | x = func(v1) |
| 313 | y = 3 |
| 314 | #bar |
| 315 | return x |
| 316 | x |
| 317 | # -------------------------------------------------- in-class-range-1 |
| 318 | class X1: |
| 319 | #? 9 text {'new_name': 'f', 'until_line': 4} |
| 320 | a = 3 |
| 321 | c = a + 2 |
| 322 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 323 | def f(): |
| 324 | a = 3 |
| 325 | c = a + 2 |
| 326 | return c |
| 327 | |
| 328 | |
| 329 | class X1: |
| 330 | #? 9 text {'new_name': 'f', 'until_line': 4} |
| 331 | c = f() |
| 332 | # -------------------------------------------------- in-method-range-1 |
| 333 | glob1 = 1 |
| 334 | class X: |
| 335 | # ha |
| 336 | def g(self): pass |
| 337 | |
| 338 | # haha |
| 339 | def f(self, b, c): |
| 340 | #? 11 text {'new_name': 'ab', 'until_line': 12, 'until_column': 28} |
| 341 | #foo |
| 342 | local1 = 3 |
| 343 | local2 = 4 |
| 344 | x= self.g() or self.f(b) ^ glob1 & b is local1 |
| 345 | # bar |
| 346 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 347 | glob1 = 1 |
| 348 | class X: |
| 349 | # ha |
| 350 | def g(self): pass |
| 351 | |
| 352 | # haha |
| 353 | def ab(self, b): |
| 354 | #foo |
| 355 | local1 = 3 |
| 356 | local2 = 4 |
| 357 | x= self.g() or self.f(b) ^ glob1 & b is local1 |
| 358 | return x |
| 359 | |
| 360 | def f(self, b, c): |
| 361 | #? 11 text {'new_name': 'ab', 'until_line': 12, 'until_column': 28} |
| 362 | x = self.ab(b) |
| 363 | # bar |
| 364 | # -------------------------------------------------- in-method-range-2 |
| 365 | glob1 = 1 |
| 366 | class X: |
| 367 | # comment |
| 368 | |
| 369 | def f(self, b, c): |
| 370 | #? 11 text {'new_name': 'ab', 'until_line': 11, 'until_column': 10} |
| 371 | #foo |
| 372 | local1 = 3 |
| 373 | local2 = 4 |
| 374 | return local1 * glob1 * b |
| 375 | # bar |
| 376 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 377 | glob1 = 1 |
| 378 | class X: |
| 379 | # comment |
| 380 | |
| 381 | def ab(self, b): |
| 382 | #foo |
| 383 | local1 = 3 |
| 384 | local2 = 4 |
| 385 | return local1 * glob1 * b |
| 386 | # bar |
| 387 | |
| 388 | def f(self, b, c): |
| 389 | #? 11 text {'new_name': 'ab', 'until_line': 11, 'until_column': 10} |
| 390 | return self.ab(b) |
| 391 | # -------------------------------------------------- in-method-range-3 |
| 392 | glob1 = 1 |
| 393 | class X: |
| 394 | def f(self, b, c): |
| 395 | local1, local2 = 3, 4 |
| 396 | #foo |
| 397 | #? 11 text {'new_name': 'ab', 'until_line': 7, 'until_column': 29} |
| 398 | return local1 & glob1 & b |
| 399 | # bar |
| 400 | local2 |
| 401 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 402 | glob1 = 1 |
| 403 | class X: |
| 404 | def ab(self, local1, b): |
| 405 | return local1 & glob1 & b |
| 406 | |
| 407 | def f(self, b, c): |
| 408 | local1, local2 = 3, 4 |
| 409 | #foo |
| 410 | #? 11 text {'new_name': 'ab', 'until_line': 7, 'until_column': 29} |
| 411 | return self.ab(local1, b) |
| 412 | # bar |
| 413 | local2 |
| 414 | # -------------------------------------------------- in-method-no-param |
| 415 | glob1 = 1 |
| 416 | class X: |
| 417 | def f(): |
| 418 | #? 11 text {'new_name': 'ab', 'until_line': 5, 'until_column': 22} |
| 419 | return glob1 + 2 |
| 420 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 421 | glob1 = 1 |
| 422 | class X: |
| 423 | def ab(): |
| 424 | return glob1 + 2 |
| 425 | |
| 426 | def f(): |
| 427 | #? 11 text {'new_name': 'ab', 'until_line': 5, 'until_column': 22} |
| 428 | return ab() |
| 429 | # -------------------------------------------------- random-return-1 |
| 430 | def x(): |
| 431 | #? 0 error {'new_name': 'ab', 'until_line': 5, 'until_column': 10} |
| 432 | if x: |
| 433 | return 1 |
| 434 | return 1 |
| 435 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 436 | Can only extract return statements if they are at the end. |
| 437 | # -------------------------------------------------- random-return-2 |
| 438 | def x(): |
| 439 | #? 0 error {'new_name': 'ab', 'until_line': 5, 'until_column': 10} |
| 440 | # |
| 441 | return |
| 442 | pass |
| 443 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 444 | Can only extract return statements if they are at the end. |
| 445 | # -------------------------------------------------- random-yield-1 |
| 446 | def x(): |
| 447 | #? 0 error {'new_name': 'ab', 'until_line': 5, 'until_column': 10} |
| 448 | # |
| 449 | if (yield 1): |
| 450 | return |
| 451 | pass |
| 452 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 453 | Cannot extract yield statements. |
| 454 | # -------------------------------------------------- random-yield-2 |
| 455 | def x(): |
| 456 | #? 0 error {'new_name': 'ab', 'until_line': 4, 'until_column': 10} |
| 457 | # |
| 458 | try: |
| 459 | yield |
| 460 | finally: |
| 461 | pass |
| 462 | # ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 463 | Cannot extract yield statements. |