Add e2e tests

This commit is contained in:
Manuel de Brito Fontes 2017-10-17 19:50:27 -03:00
parent 99a355f25d
commit 601fb7dacf
1163 changed files with 289217 additions and 14195 deletions

View file

@ -6,6 +6,7 @@ package jlexer
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
@ -1043,6 +1044,28 @@ func (r *Lexer) GetNonFatalErrors() []*LexerError {
return r.multipleErrors
}
// JsonNumber fetches and json.Number from 'encoding/json' package.
// Both int, float or string, contains them are valid values
func (r *Lexer) JsonNumber() json.Number {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() {
r.errInvalidToken("json.Number")
return json.Number("0")
}
switch r.token.kind {
case tokenString:
return json.Number(r.String())
case tokenNumber:
return json.Number(r.Raw())
default:
r.errSyntax()
return json.Number("0")
}
}
// Interface fetches an interface{} analogous to the 'encoding/json' package.
func (r *Lexer) Interface() interface{} {
if r.token.kind == tokenUndef && r.Ok() {