nushell/crates/nu-command/tests/commands/into_filesize.rs
Stefan Holderbach bbf0b45c59
Update internal use of decimal to float (#10333)
# Description
We made the decision that our floating point type should be referred to
as `float` over `decimal`.
Commands were updated by #9979 and #10320

Now make the internal codebase consistent in referring to this data type
as `float`.

Work for #10332

# User-Facing Changes

`decimal` has been removed as a type name/symbol. 

Instead of 
```nushell
def foo [bar: decimal] decimal -> decimal {}
```
use 
```nushell
def foo [bar: float] float -> float {}
```

Potential effect of `SyntaxShape`'s `Display` implementation now also
referring to `float` instead of `decimal`

# Details
- Rename `SyntaxShape::Decimal` to `Float`
- Update `Display for SyntaxShape` to `float`
- Update error message + fn name in dataframe code
- Fix docs in command examples
- Rename tests that are float specific
- Update doccomment on `SyntaxShape`
- Update comment in script

# Tests + Formatting
Updates the names of some tests
2023-09-13 23:53:55 +02:00

64 lines
1.1 KiB
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn into_filesize_int() {
let actual = nu!("1 | into filesize");
assert!(actual.out.contains("1 B"));
}
#[test]
fn into_filesize_float() {
let actual = nu!("1.2 | into filesize");
assert!(actual.out.contains("1 B"));
}
#[test]
fn into_filesize_str() {
let actual = nu!(r#"
'2000' | into filesize
"#);
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_str_newline() {
let actual = nu!(pipeline(
r#"
"2000
" | into filesize
"#
));
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_str_many_newlines() {
let actual = nu!(pipeline(
r#"
"2000
" | into filesize
"#
));
assert!(actual.out.contains("2.0 KiB"));
}
#[test]
fn into_filesize_filesize() {
let actual = nu!("3kib | into filesize");
assert!(actual.out.contains("3.0 KiB"));
}
#[test]
fn into_filesize_negative_filesize() {
let actual = nu!("-3kib | into filesize");
assert!(actual.out.contains("-3.0 KiB"));
}