Пример #1
0
def _create_tree_resource_to_struct_with_extra_folding(actual, reference):
    root = Root().insert(
        nodes.Namespace(name="ns").insert(
            nodes.Namespace(name="fold").insert(nodes.Structure(name=actual)),
            Archive(name="Archive").insert(
                res.Vector(name="resource").insert(
                    refs.StructureReference(name=reference)))))
    return SyntaxTree(root)
Пример #2
0
def _create_nested_namespaces(path):
    assert not path.startswith(Node.PATH_SEPARATOR)
    splitpath = Node.splitpath(path)
    root = nodes.Namespace(name=splitpath[0])

    node = root
    for name in splitpath[1:]:
        new_node = nodes.Namespace(name=name)
        node.insert(new_node)
        node = new_node
    return root, node
Пример #3
0
def _create_tree_resource_to_archive():
    root = Root().insert(
        nodes.Namespace(name="ns").insert(
            Archive(name="RefArchive"),
            Archive(name="Archive").insert(
                res.Archive(name="resource").insert(
                    refs.ArchiveReference(name="RefArchive")))))
    return SyntaxTree(root)
Пример #4
0
def _create_tree_with_two_struct_references():
    root = Root().insert(
        nodes.Namespace(name="ns").insert(
            nodes.Structure(name="S1"), nodes.Structure(name="S2"),
            Archive(name="Archive").insert(
                res.Multivector(name="resource").insert(
                    refs.StructureReference(name="S1"),
                    refs.StructureReference(name="S2")))))
    return SyntaxTree(root)
Пример #5
0
def _create_tree_with_explicit_reference(name):
    root = Root().insert(
        nodes.Namespace(name="ns").insert(
            nodes.Structure(name="Struct").insert(nodes.Field(name="Field")),
            Archive(name="Archive").insert(
                res.Vector(name="resource").insert(
                    refs.FieldReference(name="Struct.Field"),
                    refs.ResourceReference(name=name)),
                res.Vector(name="resource2"))))
    return SyntaxTree(root)
Пример #6
0
def test_implicit_references_structure_is_resolved():
    root = Root().insert(
        nodes.Namespace("n").insert(
            Archive("A").insert(
                res.Vector("r1"), res.Vector("r2"),
                res.BoundResource("b").insert(
                    refs.ResourceReference("A.r1"),
                    refs.ResourceReference("A.r2")))))
    resolve_references(root)
    assert_equal("@@n@A@r1", root.find('.n.A.b').children[0].name)
    assert_equal("@@n@A@r2", root.find('.n.A.b').children[1].name)