cli: Fix rendering of long integers

Recent changes to the human-readable rendering of outputs and console
values led to long integer values being presented in scientific
notation (e.g. 1.2345678e+07). While technically correct, this is an
unusual way to present integer values.

This commit changes the formatting mode to 'f', which never uses
scientific notation and displays integer values as a sequence of digits
instead (e.g. 12345678).
This commit is contained in:
Alisdair McDiarmid 2021-01-07 16:29:49 -05:00
parent bc46ff545e
commit d763e4f73e
2 changed files with 13 additions and 1 deletions

View File

@ -52,7 +52,7 @@ func FormatValue(v cty.Value, indent int) string {
return strconv.Quote(v.AsString())
case cty.Number:
bf := v.AsBigFloat()
return bf.Text('g', -1)
return bf.Text('f', -1)
case cty.Bool:
if v.True() {
return "true"

View File

@ -89,10 +89,22 @@ EOT_`,
cty.NumberIntVal(5),
`5`,
},
{
cty.NumberIntVal(1234567890),
`1234567890`,
},
{
cty.NumberFloatVal(5.2),
`5.2`,
},
{
cty.NumberFloatVal(123456789.0),
`123456789`,
},
{
cty.NumberFloatVal(123456789.01),
`123456789.01`,
},
{
cty.False,
`false`,