Ejemplo n.º 1
0
def test_apply(smart_repo: SmartRepo):
    state = TreeBackedRepoState(smart_repo, smart_repo.head.commit.tree)
    change = VariableRenamed(smart_repo.find_cursor('a.c', lambda cur: cur.kind == CursorKind.VAR_DECL
                                                                       and cur.spelling == 'a'), 'meow')
    change.apply(smart_repo, state)
    assert state['a.c'] == as_lines('int main() {',
                                    '    int meow = 0;',
                                    '    return meow + (meow - 1);',
                                    '}')
Ejemplo n.º 2
0
def test_detect(smart_repo: SmartRepo):
    a = smart_repo.find_cursor('a.c', lambda c: c.spelling == 'b').drop(1).appended('a')
    assert get_changes(smart_repo) == [[FileAdded('a.c', smart_repo.contents('a.c', 'initial'))],
                                       [VariableRenamed(a, 'b')]]