Skip to content

Commit

Permalink
modify make token by byte position, not rune position at readName
Browse files Browse the repository at this point in the history
  • Loading branch information
takeshi.nakata committed Jun 9, 2021
1 parent 8a92e97 commit ea0716e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
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

0 comments on commit ea0716e

Please sign in to comment.