forked from extern/nushell
Another batch of command tests (#4496)
* Add a batch of command tests * More tests
This commit is contained in:
2
crates/nu-command/src/env/with_env.rs
vendored
2
crates/nu-command/src/env/with_env.rs
vendored
@ -24,7 +24,7 @@ impl Command for WithEnv {
|
||||
)
|
||||
.required(
|
||||
"block",
|
||||
SyntaxShape::Block(Some(vec![SyntaxShape::Any])),
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"the block to run once the variable is set",
|
||||
)
|
||||
.category(Category::Env)
|
||||
|
@ -164,7 +164,7 @@ fn get_cellpath_columns(keep_cols: Vec<String>, span: Span) -> Vec<CellPath> {
|
||||
fn get_keep_columns(mut input: Vec<String>, rejects: Vec<String>) -> Vec<String> {
|
||||
for reject in rejects {
|
||||
if let Some(index) = input.iter().position(|value| *value == reject) {
|
||||
input.swap_remove(index);
|
||||
input.remove(index);
|
||||
}
|
||||
}
|
||||
input
|
||||
@ -173,8 +173,8 @@ fn get_keep_columns(mut input: Vec<String>, rejects: Vec<String>) -> Vec<String>
|
||||
fn reject_record_columns(cols: &mut Vec<String>, vals: &mut Vec<Value>, rejects: &[String]) {
|
||||
for reject in rejects {
|
||||
if let Some(index) = cols.iter().position(|value| value == reject) {
|
||||
cols.swap_remove(index);
|
||||
vals.swap_remove(index);
|
||||
cols.remove(index);
|
||||
vals.remove(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,13 @@ fn decimal(
|
||||
let range: Option<Range> = call.opt(engine_state, stack, 0)?;
|
||||
|
||||
let (min, max) = if let Some(r) = range {
|
||||
(r.from.as_float()?, r.to.as_float()?)
|
||||
if r.is_end_inclusive() {
|
||||
(r.from.as_float()?, r.to.as_float()?)
|
||||
} else if r.to.as_float()? >= 1.0 {
|
||||
(r.from.as_float()?, r.to.as_float()? - 1.0)
|
||||
} else {
|
||||
(0.0, 0.0)
|
||||
}
|
||||
} else {
|
||||
(0.0, 1.0)
|
||||
};
|
||||
|
@ -70,7 +70,13 @@ fn integer(
|
||||
let range: Option<Range> = call.opt(engine_state, stack, 0)?;
|
||||
|
||||
let (min, max) = if let Some(r) = range {
|
||||
(r.from.as_integer()?, r.to.as_integer()?)
|
||||
if r.is_end_inclusive() {
|
||||
(r.from.as_integer()?, r.to.as_integer()?)
|
||||
} else if r.to.as_integer()? > 0 {
|
||||
(r.from.as_integer()?, r.to.as_integer()? - 1)
|
||||
} else {
|
||||
(0, 0)
|
||||
}
|
||||
} else {
|
||||
(0, i64::MAX)
|
||||
};
|
||||
|
Reference in New Issue
Block a user