mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 17:54:22 +02:00
Further cleanup of Span::test_data
usage + span fixes (#7595)
# Description Inspired by #7592 For brevity use `Value::test_{string,int,float,bool}` Includes fixes to commands that were abusing `Span::test_data` in their implementation. Now the call span is used where possible or the explicit `Span::unknonw` is used. ## Command fixes - Fix abuse of `Span::test_data()` in `query_xml` - Fix abuse of `Span::test_data()` in `term size` - Fix abuse of `Span::test_data()` in `seq date` - Fix two abuses of `Span::test_data` in `nu-cli` - Change `Span::test_data` to `Span::unknown` in `keybindings listen` - Add proper call span to `registry query` - Fix span use in `nu_plugin_query` - Fix span assignment in `select` - Use `Span::unknown` instead of `test_data` in more places ## Other - Use `Value::test_int`/`test_float()` consistently - More `test_string` and `test_bool` - Fix unused imports # User-Facing Changes Some commands may now provide more helpful spans for downstream use in errors
This commit is contained in:
committed by
GitHub
parent
dd6fe6a04a
commit
45fe3be83e
@ -46,7 +46,7 @@ impl Command for SubCommand {
|
||||
result: Some(Value::List {
|
||||
vals: vec![
|
||||
Value::test_int(50),
|
||||
Value::float(100.0, Span::test_data()),
|
||||
Value::test_float(100.0),
|
||||
Value::test_int(25),
|
||||
],
|
||||
span: Span::test_data(),
|
||||
|
@ -40,7 +40,7 @@ impl Command for SubCommand {
|
||||
vec![Example {
|
||||
description: "Compute the average of a list of numbers",
|
||||
example: "[-50 100.0 25] | math avg",
|
||||
result: Some(Value::float(25.0, Span::test_data())),
|
||||
result: Some(Value::test_float(25.0)),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ impl Command for SubCommand {
|
||||
vec![Example {
|
||||
description: "Evaluate math in the pipeline",
|
||||
example: "'10 / 4' | math eval",
|
||||
result: Some(Value::float(2.5, Span::test_data())),
|
||||
result: Some(Value::test_float(2.5)),
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl Command for SubCommand {
|
||||
Example {
|
||||
description: "Compute the median of a list of numbers",
|
||||
example: "[3 8 9 12 12 15] | math median",
|
||||
result: Some(Value::float(10.5, Span::test_data())),
|
||||
result: Some(Value::test_float(10.5)),
|
||||
},
|
||||
Example {
|
||||
description: "Compute the medians of the columns of a table",
|
||||
|
@ -68,9 +68,9 @@ impl Command for SubCommand {
|
||||
example: "[1.555 2.333 -3.111] | math round -p 2",
|
||||
result: Some(Value::List {
|
||||
vals: vec![
|
||||
Value::float(1.56, Span::test_data()),
|
||||
Value::float(2.33, Span::test_data()),
|
||||
Value::float(-3.11, Span::test_data()),
|
||||
Value::test_float(1.56),
|
||||
Value::test_float(2.33),
|
||||
Value::test_float(-3.11),
|
||||
],
|
||||
span: Span::test_data(),
|
||||
}),
|
||||
|
@ -54,12 +54,12 @@ impl Command for SubCommand {
|
||||
Example {
|
||||
description: "Compute the standard deviation of a list of numbers",
|
||||
example: "[1 2 3 4 5] | math stddev",
|
||||
result: Some(Value::float(std::f64::consts::SQRT_2, Span::test_data())),
|
||||
result: Some(Value::test_float(std::f64::consts::SQRT_2)),
|
||||
},
|
||||
Example {
|
||||
description: "Compute the sample standard deviation of a list of numbers",
|
||||
example: "[1 2 3 4 5] | math stddev -s",
|
||||
result: Some(Value::float(1.5811388300841898, Span::test_data())),
|
||||
result: Some(Value::test_float(1.5811388300841898)),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ impl Command for SubCommand {
|
||||
Example {
|
||||
description: "Get the variance of a list of numbers",
|
||||
example: "[1 2 3 4 5] | math variance",
|
||||
result: Some(Value::float(2.0, Span::test_data())),
|
||||
result: Some(Value::test_float(2.0)),
|
||||
},
|
||||
Example {
|
||||
description: "Get the sample variance of a list of numbers",
|
||||
example: "[1 2 3 4 5] | math variance -s",
|
||||
result: Some(Value::float(2.5, Span::test_data())),
|
||||
result: Some(Value::test_float(2.5)),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user