# Path: supplement/evaluator.py
# def infer(string, scope, lineno=None):
#     tree = ast.parse(string, '<string>', 'eval')
# 
#     if lineno:
#         ast.increment_lineno(tree, lineno-1)
# 
#     return Evaluator().process(tree, scope)
# 
# Path: supplement/scope.py
# class StaticScope(object):
#     def __init__(self, fullname, project, filename=None):
#         self._names = {}
#         self.parent = None
#         self.fullname = fullname
#         self.project = project
#         self.filename = filename
# 
#     def get_names(self):
#         return self._names
# 
#     def find_name(self, name, lineno=None):
#         return Scope.__dict__['find_name'](self, name, lineno)
# 
#     def __contains__(self, name):
#         return name in self._names
# 
#     def __getitem__(self, name):
#         return self._names[name]
# 
#     def get_name(self, name, lineno=None):
#         return self._names[name]
# 
# def get_scope_at(project, source, lineno, filename=None, ast_node=None, continous=True):
#     ast_node = ast_node or ast.parse(source)
# 
#     scope = Scope(ast_node, '', None, 'module')
#     scope.project = project
#     scope.filename = filename
#     return scope.get_scope_at(source, lineno, continous)
# 
# Path: supplement/common.py
# class UnknownObject(Object): pass
# 
# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p
# 
# def cleantabs(text):
#     lines = text.splitlines()
#     if not lines[0].strip():
#         lines = lines[1:]
# 
#     toremove = 999
#     for l in lines:
#         stripped = l.lstrip()
#         if stripped:
#             toremove = min(toremove, len(l) - len(stripped))
# 
#     if toremove < 999:
#         return '\n'.join(l[toremove:] for l in lines)
#     else:
#         return '\n'.join(lines)


from supplement.evaluator import infer
from supplement.scope import StaticScope, get_scope_at
from supplement.common import UnknownObject
from .helpers import pytest_funcarg__project, cleantabs
    scope = project.create_scope('''
        def foo(name, opt=[]):
            return opt
    ''')

    obj = infer("foo('name')", scope, 100)
    assert 'append' in obj

def test_function_call_with_starargs(project):
    scope = project.create_scope('''
        def foo(*args):
            return args[1]
    ''')

    obj = infer("foo('name', [])", scope, 100)
    assert 'append' in obj

def test_compare_expression(scope):
    obj = infer("5 in (1,2,3)", scope, 100)
    assert 'bit_length' in obj

def test_generator_expression(project):
    pass

def test_empty_return(project):
    scope = project.create_scope('''
        def foo():
            return
    ''')
    obj = infer('foo()', scope, 100)

# Path: supplement/evaluator.py
# def infer(string, scope, lineno=None):
#     tree = ast.parse(string, '<string>', 'eval')
# 
#     if lineno:
#         ast.increment_lineno(tree, lineno-1)
# 
#     return Evaluator().process(tree, scope)
# 
# Path: supplement/scope.py
# class StaticScope(object):
#     def __init__(self, fullname, project, filename=None):
#         self._names = {}
#         self.parent = None
#         self.fullname = fullname
#         self.project = project
#         self.filename = filename
# 
#     def get_names(self):
#         return self._names
# 
#     def find_name(self, name, lineno=None):
#         return Scope.__dict__['find_name'](self, name, lineno)
# 
#     def __contains__(self, name):
#         return name in self._names
# 
#     def __getitem__(self, name):
#         return self._names[name]
# 
#     def get_name(self, name, lineno=None):
#         return self._names[name]
# 
# def get_scope_at(project, source, lineno, filename=None, ast_node=None, continous=True):
#     ast_node = ast_node or ast.parse(source)
# 
#     scope = Scope(ast_node, '', None, 'module')
#     scope.project = project
#     scope.filename = filename
#     return scope.get_scope_at(source, lineno, continous)
# 
# Path: supplement/common.py
# class UnknownObject(Object): pass
# 
# Path: tests/helpers.py
# def pytest_funcarg__project(request):
#     for crap_module in ('toimport', 'package'):
#         if crap_module in sys.modules:
#             del sys.modules[crap_module]
# 
#     p = Project('.')
#     p.create_module = create_module.__get__(p, Project)
#     p.create_scope = create_scope.__get__(p, Project)
#     p.set_root = set_project_root.__get__(p, Project)
#     return p
# 
# def cleantabs(text):
#     lines = text.splitlines()
#     if not lines[0].strip():
#         lines = lines[1:]
# 
#     toremove = 999
#     for l in lines:
#         stripped = l.lstrip()
#         if stripped:
#             toremove = min(toremove, len(l) - len(stripped))
# 
#     if toremove < 999:
#         return '\n'.join(l[toremove:] for l in lines)
#     else:
#         return '\n'.join(lines)


# Path: tests/test_evaluator.py
from supplement.evaluator import infer
from supplement.scope import StaticScope, get_scope_at
from supplement.common import UnknownObject
from .helpers import pytest_funcarg__project, cleantabs

    scope = project.create_scope('''
        def foo(name, opt=[]):
            return opt
    ''')

    obj = infer("foo('name')", scope, 100)
    assert 'append' in obj

def test_function_call_with_starargs(project):
    scope = project.create_scope('''
        def foo(*args):
            return args[1]
    ''')

    obj = infer("foo('name', [])", scope, 100)
    assert 'append' in obj

def test_compare_expression(scope):
    obj = infer("5 in (1,2,3)", scope, 100)
    assert 'bit_length' in obj

def test_generator_expression(project):
    pass

def test_empty_return(project):
    scope = project.create_scope('''
        def foo():
            return
    ''')
    obj = infer('foo()', scope, 100)

    assert isinstance(obj, UnknownObject)