# Path: pycc/asttools/references.py
# def add_parent_references(node):
# def add_sibling_references(node):
# def copy_location(new_node, old_node):
# def get_top_node(node):


import ast
import pytest
from pycc.asttools import references
    assert node.parent is None


def test_sibling_references(node):
    """Test that sibling references are added to child nodes."""
    references.add_sibling_references(node)

    assert node.targets[0].previous is None
    assert node.targets[0].next is node.value
    assert node.value.previous is node.targets[0]


def test_copy_location(node):
    """Test that references are preserved by the custom copy_location."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    original = node.targets[0]
    dupe = references.copy_location(
        ast.Name(id='y', ctx=ast.Store()),
        original,
    )

    assert dupe.parent is original.parent
    assert dupe.previous is original.previous
    assert dupe.next is original.next


def test_get_top_node(node):
    """Test that the root node can be retrieved from any node."""

# Path: pycc/asttools/references.py
# def add_parent_references(node):
# def add_sibling_references(node):
# def copy_location(new_node, old_node):
# def get_top_node(node):


# Path: tests/asttools/test_references.py
import ast
import pytest
from pycc.asttools import references

    assert node.parent is None


def test_sibling_references(node):
    """Test that sibling references are added to child nodes."""
    references.add_sibling_references(node)

    assert node.targets[0].previous is None
    assert node.targets[0].next is node.value
    assert node.value.previous is node.targets[0]


def test_copy_location(node):
    """Test that references are preserved by the custom copy_location."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    original = node.targets[0]
    dupe = references.copy_location(
        ast.Name(id='y', ctx=ast.Store()),
        original,
    )

    assert dupe.parent is original.parent
    assert dupe.previous is original.previous
    assert dupe.next is original.next


def test_get_top_node(node):
    """Test that the root node can be retrieved from any node."""

    references.add_parent_references(node)