Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify making token by byte position, not rune position at readName #605

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion language/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func readName(source *source.Source, position, runePosition int) Token {
break
}
}
return makeToken(NAME, runePosition, endRune, string(body[position:endByte]))
return makeToken(NAME, position, endByte, string(body[position:endByte]))
}

// Reads a number token from the source file, either a float
Expand Down
4 changes: 2 additions & 2 deletions language/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func TestLexer_AcceptsBOMHeader(t *testing.T) {
Body: "\uFEFF foo",
Expected: Token{
Kind: NAME,
Start: 2,
End: 5,
Start: 4,
End: 7,
Value: "foo",
},
},
Expand Down
13 changes: 13 additions & 0 deletions language/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,19 @@ func TestParsesEnumValueDefinitionWithDescription(t *testing.T) {
}
}

func TestParsesTypeDefinitionWithMultiByteCharactersComment_UnicodeText(t *testing.T) {
source := `
# This comment has a фы世界 character.
type Foo implements Bar {
foo: String!
}
`
_, err := Parse(ParseParams{Source: source})
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
}

func TestDefinitionsWithDescriptions(t *testing.T) {
testCases := []struct {
name string
Expand Down