Fixed errors doubling

This commit is contained in:
Aleksandr Petrukhin
2016-12-20 17:22:42 +03:00
parent 3b6b44b81e
commit 3c64f7b0b1
2 changed files with 15 additions and 2 deletions
-2
View File
@@ -652,8 +652,6 @@ func (r *Lexer) number() string {
}
if !r.Ok() || r.token.kind != tokenNumber {
if *UseSemanticErrors {
r.errSemantic()
r.SkipRecursive()
return ""
}
r.errInvalidToken("number")
+15
View File
@@ -209,6 +209,9 @@ func TestNestedEasyJsonMarshal(t *testing.T) {
}
func TestSemanticErrors(t *testing.T) {
if !*jlexer.UseSemanticErrors {
return
}
for i, test := range []struct {
Data []byte
ErrorNum int
@@ -217,6 +220,18 @@ func TestSemanticErrors(t *testing.T) {
Data: []byte(`[1, 2, 3, "4", "5"]`),
ErrorNum: 2,
},
{
Data: []byte(`[1, {"2" : "3"}, 3, "4"`),
ErrorNum: 2,
},
{
Data: []byte(`[1, "2", "3", "4", "5", "6"]`),
ErrorNum: 5,
},
{
Data: []byte(`[1, 2, 3, 4, "5"]`),
ErrorNum: 1,
},
} {
l := jlexer.Lexer{Data: test.Data}