mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Return errors on unexpected inputs to take
and first
(#7123)
* Fix `take` behaviour for unexpected input types * Fix `first` behaviour for unexpected input types * Fix copy paste mistake
This commit is contained in:
@ -41,3 +41,28 @@ fn rows_with_no_arguments_should_lead_to_error() {
|
||||
assert!(actual.err.contains("missing_positional"));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fails_on_string() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
"foo bar" | take 2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("unsupported_input"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
// covers a situation where `take` used to behave strangely on list<binary> input
|
||||
fn works_with_binary_list() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
([0x[01 11]] | take 1 | get 0) == 0x[01 11]
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
Reference in New Issue
Block a user