func TestSchemaParser_DoubleValueEnum(t *testing.T) { body := `enum Hello { WO, RLD }` astDoc := parse(t, body) expected := ast.NewDocument(&ast.Document{ Loc: loc(0, 22), Definitions: []ast.Node{ ast.NewEnumTypeDefinition(&ast.EnumTypeDefinition{ Loc: loc(0, 22), Name: ast.NewName(&ast.Name{ Value: "Hello", Loc: loc(5, 10), }), Values: []*ast.EnumValueDefinition{ ast.NewEnumValueDefinition(&ast.EnumValueDefinition{ Name: ast.NewName(&ast.Name{ Value: "WO", Loc: loc(13, 15), }), Loc: loc(13, 15), }), ast.NewEnumValueDefinition(&ast.EnumValueDefinition{ Name: ast.NewName(&ast.Name{ Value: "RLD", Loc: loc(17, 20), }), Loc: loc(17, 20), }), }, }), }, }) if !reflect.DeepEqual(astDoc, expected) { t.Fatalf("unexpected document, expected: %v, got: %v", expected, astDoc) } }
func parseEnumValueDefinition(parser *Parser) (interface{}, error) { start := parser.Token.Start name, err := parseName(parser) if err != nil { return nil, err } return ast.NewEnumValueDefinition(&ast.EnumValueDefinition{ Name: name, Loc: loc(parser, start), }), nil }