Force floats to output a decimal in nuon (#5768)

* Force floats to output a decimal in nuon

* Add test
This commit is contained in:
JT
2022-06-14 05:45:07 +12:00
committed by GitHub
parent 9dbf7556b8
commit 7ae7394c85
2 changed files with 19 additions and 1 deletions

View File

@ -86,7 +86,13 @@ fn value_to_string(v: &Value, span: Span) -> Result<String, ShellError> {
span,
)),
Value::Filesize { val, .. } => Ok(format!("{}b", *val)),
Value::Float { val, .. } => Ok(format!("{}", *val)),
Value::Float { val, .. } => {
if &val.round() == val {
Ok(format!("{}.0", *val))
} else {
Ok(format!("{}", *val))
}
}
Value::Int { val, .. } => Ok(format!("{}", *val)),
Value::List { vals, .. } => {
let headers = get_columns(vals);