mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Add accidentally missing tests of some command examples (#7035)
* Add missing tests of examples * Fix broken tests due to externals not being in working set * Comment out `where` test due to bug
This commit is contained in:
parent
8a812cf03c
commit
5ee7847035
@ -46,14 +46,14 @@ impl Command for Length {
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
description: "Count the number of entries in a list",
|
||||
example: "echo [1 2 3 4 5] | length",
|
||||
description: "Count the number of items in a list",
|
||||
example: "[1 2 3 4 5] | length",
|
||||
result: Some(Value::test_int(5)),
|
||||
},
|
||||
Example {
|
||||
description: "Count the number of columns in the calendar table",
|
||||
example: "cal | length -c",
|
||||
result: Some(Value::test_int(7)),
|
||||
description: "Count the number of columns in a table",
|
||||
example: "[{columnA: A0 columnB: B0}] | length -c",
|
||||
result: Some(Value::test_int(2)),
|
||||
},
|
||||
]
|
||||
}
|
||||
@ -122,3 +122,15 @@ fn getcol(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(Length {})
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ impl Command for Lines {
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
description: "Split multi-line string into lines",
|
||||
example: "echo $'two(char nl)lines' | lines",
|
||||
example: r#"echo $"two\nlines" | lines"#,
|
||||
result: Some(Value::List {
|
||||
vals: vec![Value::test_string("two"), Value::test_string("lines")],
|
||||
span: Span::test_data(),
|
||||
@ -252,3 +252,15 @@ impl RawStreamLinesAdapter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(Lines {})
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{CaptureBlock, Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError,
|
||||
Signature, Span, SyntaxShape, Value,
|
||||
Signature, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -238,23 +238,37 @@ impl Command for Where {
|
||||
example: "ls | where modified >= (date now) - 2wk",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Get all numbers above 3 with an existing block condition",
|
||||
example: "let a = {$in > 3}; [1, 2, 5, 6] | where -b $a",
|
||||
result: Some(Value::List {
|
||||
vals: vec![
|
||||
Value::Int {
|
||||
val: 5,
|
||||
span: Span::test_data(),
|
||||
},
|
||||
Value::Int {
|
||||
val: 6,
|
||||
span: Span::test_data(),
|
||||
},
|
||||
],
|
||||
span: Span::test_data(),
|
||||
}),
|
||||
},
|
||||
// TODO: This should work but does not. (Note that `Let` must be present in the working_set in `example_test.rs`).
|
||||
// See https://github.com/nushell/nushell/issues/7034
|
||||
// Example {
|
||||
// description: "Get all numbers above 3 with an existing block condition",
|
||||
// example: "let a = {$in > 3}; [1, 2, 5, 6] | where -b $a",
|
||||
// result: Some(Value::List {
|
||||
// vals: vec![
|
||||
// Value::Int {
|
||||
// val: 5,
|
||||
// span: Span::test_data(),
|
||||
// },
|
||||
// Value::Int {
|
||||
// val: 6,
|
||||
// span: Span::test_data(),
|
||||
// },
|
||||
// ],
|
||||
// span: Span::test_data(),
|
||||
// }),
|
||||
// },
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(Where {})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user