hcl/token: add Value for IDENT
This commit is contained in:
parent
798e1c6c05
commit
16ce140272
@ -133,6 +133,8 @@ func (t Token) Value() interface{} {
|
||||
}
|
||||
|
||||
return int64(v)
|
||||
case IDENT:
|
||||
return t.Text
|
||||
case STRING:
|
||||
// It is wrapped in quotes always
|
||||
return t.Text[1 : len(t.Text)-1]
|
||||
|
@ -47,6 +47,7 @@ func TestTokenValue(t *testing.T) {
|
||||
{Token{Type: BOOL, Text: `false`}, false},
|
||||
{Token{Type: FLOAT, Text: `3.14`}, float64(3.14)},
|
||||
{Token{Type: NUMBER, Text: `42`}, int64(42)},
|
||||
{Token{Type: IDENT, Text: `foo`}, "foo"},
|
||||
{Token{Type: STRING, Text: `"foo"`}, "foo"},
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user