mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
add some more test for inline errors
This commit is contained in:
@@ -149,10 +149,10 @@ def inline(grammar, names):
|
|||||||
expr_stmt = tree_name.get_definition()
|
expr_stmt = tree_name.get_definition()
|
||||||
if expr_stmt.type != 'expr_stmt':
|
if expr_stmt.type != 'expr_stmt':
|
||||||
type_ = dict(
|
type_ = dict(
|
||||||
funcdef='a function',
|
funcdef='function',
|
||||||
classdef='a class',
|
classdef='class',
|
||||||
).get(expr_stmt.type, expr_stmt.type)
|
).get(expr_stmt.type, expr_stmt.type)
|
||||||
raise RefactoringError("Cannot inline %s" % type_)
|
raise RefactoringError("Cannot inline a %s" % type_)
|
||||||
|
|
||||||
if len(expr_stmt.get_defined_names(include_setitem=True)) > 1:
|
if len(expr_stmt.get_defined_names(include_setitem=True)) > 1:
|
||||||
raise RefactoringError("Cannot inline a statement with multiple definitions")
|
raise RefactoringError("Cannot inline a statement with multiple definitions")
|
||||||
|
|||||||
@@ -65,6 +65,25 @@ from import_tree import some_mod
|
|||||||
test(some_mod)
|
test(some_mod)
|
||||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
Cannot inline imports or modules
|
Cannot inline imports or modules
|
||||||
|
# -------------------------------------------------- class
|
||||||
|
class A: pass
|
||||||
|
#? 5 error
|
||||||
|
test(A)
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
Cannot inline a class
|
||||||
|
# -------------------------------------------------- function
|
||||||
|
def foo(a):
|
||||||
|
return a + 1
|
||||||
|
#? 5 error
|
||||||
|
test(foo(1))
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
Cannot inline a function
|
||||||
|
# -------------------------------------------------- for-stmt
|
||||||
|
for x in []:
|
||||||
|
#? 9 error
|
||||||
|
test(x)
|
||||||
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
Cannot inline a for_stmt
|
||||||
# -------------------------------------------------- simple
|
# -------------------------------------------------- simple
|
||||||
def test():
|
def test():
|
||||||
#? 4
|
#? 4
|
||||||
|
|||||||
Reference in New Issue
Block a user