summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/hcl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/hcl')
-rw-r--r--vendor/github.com/hashicorp/hcl/decoder.go2
-rw-r--r--vendor/github.com/hashicorp/hcl/decoder_test.go9
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/parser/parser.go14
-rw-r--r--vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl1
-rw-r--r--vendor/github.com/hashicorp/hcl/test-fixtures/float.json3
5 files changed, 23 insertions, 6 deletions
diff --git a/vendor/github.com/hashicorp/hcl/decoder.go b/vendor/github.com/hashicorp/hcl/decoder.go
index 6e75ece8e..b88f322a8 100644
--- a/vendor/github.com/hashicorp/hcl/decoder.go
+++ b/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
diff --git a/vendor/github.com/hashicorp/hcl/decoder_test.go b/vendor/github.com/hashicorp/hcl/decoder_test.go
index 38363ad1b..8682f470e 100644
--- a/vendor/github.com/hashicorp/hcl/decoder_test.go
+++ b/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) {
diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
index b4881806e..098e1bc49 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
+++ b/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
diff --git a/vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl b/vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl
index eed44e542..edf355e38 100644
--- a/vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl
+++ b/vendor/github.com/hashicorp/hcl/test-fixtures/float.hcl
@@ -1 +1,2 @@
a = 1.02
+b = 2
diff --git a/vendor/github.com/hashicorp/hcl/test-fixtures/float.json b/vendor/github.com/hashicorp/hcl/test-fixtures/float.json
index a9d1ab4b0..580868043 100644
--- a/vendor/github.com/hashicorp/hcl/test-fixtures/float.json
+++ b/vendor/github.com/hashicorp/hcl/test-fixtures/float.json
@@ -1,3 +1,4 @@
{
- "a": 1.02
+ "a": 1.02,
+ "b": 2
}