Этот коммит содержится в:
Christopher Speller
2017-09-29 12:46:30 -07:00
коммит произвёл GitHub
родитель 8b9dbb8613
Коммит b84736e9b6
422 изменённых файлов: 39231 добавлений и 28592 удалений

2
vendor/github.com/hashicorp/hcl/decoder.go сгенерированный поставляемый
Просмотреть файл

@@ -137,7 +137,7 @@ func (d *decoder) decodeBool(name string, node ast.Node, result reflect.Value) e
func (d *decoder) decodeFloat(name string, node ast.Node, result reflect.Value) error {
switch n := node.(type) {
case *ast.LiteralType:
if n.Token.Type == token.FLOAT {
if n.Token.Type == token.FLOAT || n.Token.Type == token.NUMBER {
v, err := strconv.ParseFloat(n.Token.Text, 64)
if err != nil {
return err

9
vendor/github.com/hashicorp/hcl/decoder_test.go сгенерированный поставляемый
Просмотреть файл

@@ -73,6 +73,7 @@ func TestDecode_interface(t *testing.T) {
false,
map[string]interface{}{
"a": 1.02,
"b": 2,
},
},
{
@@ -811,6 +812,7 @@ func TestDecode_intString(t *testing.T) {
func TestDecode_float32(t *testing.T) {
var value struct {
A float32 `hcl:"a"`
B float32 `hcl:"b"`
}
err := Decode(&value, testReadFile(t, "float.hcl"))
@@ -821,11 +823,15 @@ func TestDecode_float32(t *testing.T) {
if got, want := value.A, float32(1.02); got != want {
t.Fatalf("wrong result %#v; want %#v", got, want)
}
if got, want := value.B, float32(2); got != want {
t.Fatalf("wrong result %#v; want %#v", got, want)
}
}
func TestDecode_float64(t *testing.T) {
var value struct {
A float64 `hcl:"a"`
B float64 `hcl:"b"`
}
err := Decode(&value, testReadFile(t, "float.hcl"))
@@ -836,6 +842,9 @@ func TestDecode_float64(t *testing.T) {
if got, want := value.A, float64(1.02); got != want {
t.Fatalf("wrong result %#v; want %#v", got, want)
}
if got, want := value.B, float64(2); got != want {
t.Fatalf("wrong result %#v; want %#v", got, want)
}
}
func TestDecode_intStringAliased(t *testing.T) {

14
vendor/github.com/hashicorp/hcl/hcl/parser/parser.go сгенерированный поставляемый
Просмотреть файл

@@ -197,9 +197,12 @@ func (p *Parser) objectItem() (*ast.ObjectItem, error) {
keyStr = append(keyStr, k.Token.Text)
}
return nil, fmt.Errorf(
"key '%s' expected start of object ('{') or assignment ('=')",
strings.Join(keyStr, " "))
return nil, &PosError{
Pos: p.tok.Pos,
Err: fmt.Errorf(
"key '%s' expected start of object ('{') or assignment ('=')",
strings.Join(keyStr, " ")),
}
}
// do a look-ahead for line comment
@@ -319,7 +322,10 @@ func (p *Parser) objectType() (*ast.ObjectType, error) {
// No error, scan and expect the ending to be a brace
if tok := p.scan(); tok.Type != token.RBRACE {
return nil, fmt.Errorf("object expected closing RBRACE got: %s", tok.Type)
return nil, &PosError{
Pos: tok.Pos,
Err: fmt.Errorf("object expected closing RBRACE got: %s", tok.Type),
}
}
o.List = l

1
vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl сгенерированный поставляемый
Просмотреть файл

@@ -1 +1,2 @@
a = 1.02
b = 2

3
vendor/github.com/hashicorp/hcl/test-fixtures/float.json сгенерированный поставляемый
Просмотреть файл

@@ -1,3 +1,4 @@
{
"a": 1.02
"a": 1.02,
"b": 2
}