Exemplo n.º 1
0
def test_parses_double_value_enum():
    # type: () -> None
    body = "enum Hello { WO, RLD }"
    loc = create_loc_fn(body)
    doc = parse(body)
    expected = ast.Document(
        definitions=[
            ast.EnumTypeDefinition(
                name=ast.Name(value="Hello", loc=loc(5, 10)),
                directives=[],
                values=[
                    ast.EnumValueDefinition(
                        name=ast.Name(value="WO", loc=loc(13, 15)),
                        directives=[],
                        loc=loc(13, 15),
                    ),
                    ast.EnumValueDefinition(
                        name=ast.Name(value="RLD", loc=loc(17, 20)),
                        directives=[],
                        loc=loc(17, 20),
                    ),
                ],
                loc=loc(0, 22),
            )
        ],
        loc=loc(0, 22),
    )

    assert doc == expected
Exemplo n.º 2
0
def test_parses_single_value_enum():
    body = 'enum Hello { WORLD }'
    loc = create_loc_fn(body)
    doc = parse(body)
    expected = ast.Document(definitions=[
        ast.EnumTypeDefinition(name=ast.Name(value='Hello', loc=loc(5, 10)),
                               values=[
                                   ast.EnumValueDefinition(name=ast.Name(
                                       value='WORLD', loc=loc(13, 18)),
                                                           loc=loc(13, 18))
                               ],
                               loc=loc(0, 20))
    ],
                            loc=loc(0, 20))

    assert doc == expected
Exemplo n.º 3
0
def test_parses_double_value_enum():
    body = 'enum Hello { WO, RLD }'
    loc = create_loc_fn(body)
    doc = parse(body)
    expected = ast.Document(definitions=[
        ast.EnumTypeDefinition(
            name=ast.Name(value='Hello', loc=loc(5, 10)),
            directives=[],
            values=[
                ast.EnumValueDefinition(name=ast.Name(value='WO',
                                                      loc=loc(13, 15)),
                                        directives=[],
                                        loc=loc(13, 15)),
                ast.EnumValueDefinition(name=ast.Name(value='RLD',
                                                      loc=loc(17, 20)),
                                        directives=[],
                                        loc=loc(17, 20))
            ],
            loc=loc(0, 22))
    ],
                            loc=loc(0, 22))

    assert doc == expected