mirror of
https://github.com/nushell/nushell.git
synced 2025-02-18 03:21:05 +01:00
Fix parsing of invocations with a dot (#1804)
This commit is contained in:
parent
40ec8c41a0
commit
f43ed23ed7
@ -93,6 +93,9 @@ fn parse_full_column_path(
|
|||||||
if c == delimiter {
|
if c == delimiter {
|
||||||
inside_delimiter = false;
|
inside_delimiter = false;
|
||||||
}
|
}
|
||||||
|
} else if c == '(' {
|
||||||
|
inside_delimiter = true;
|
||||||
|
delimiter = ')';
|
||||||
} else if c == '\'' || c == '"' {
|
} else if c == '\'' || c == '"' {
|
||||||
inside_delimiter = true;
|
inside_delimiter = true;
|
||||||
delimiter = c;
|
delimiter = c;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
use nu_test_support::fs::Stub::EmptyFile;
|
||||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||||
use nu_test_support::nu;
|
use nu_test_support::nu;
|
||||||
use nu_test_support::{pipeline, playground::Playground};
|
use nu_test_support::pipeline;
|
||||||
|
use nu_test_support::playground::Playground;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
|
fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
|
||||||
@ -32,6 +34,72 @@ fn takes_rows_of_nu_value_strings_and_pipes_it_to_stdin_of_external() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn proper_it_expansion() {
|
||||||
|
Playground::setup("ls_test_1", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![
|
||||||
|
EmptyFile("andres.txt"),
|
||||||
|
EmptyFile("gedge.txt"),
|
||||||
|
EmptyFile("jonathan.txt"),
|
||||||
|
EmptyFile("yehuda.txt"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(), pipeline(
|
||||||
|
r#"
|
||||||
|
ls | sort-by name | group-by type | each { get File.name | echo $it } | to json
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
actual.out,
|
||||||
|
r#"["andres.txt","gedge.txt","jonathan.txt","yehuda.txt"]"#
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn argument_invocation() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".",
|
||||||
|
r#"
|
||||||
|
echo "foo" | echo $(echo $it)
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn invocation_handles_dot() {
|
||||||
|
Playground::setup("invocation_handles_dot", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
|
"nu_times.csv",
|
||||||
|
r#"
|
||||||
|
name,rusty_luck,origin
|
||||||
|
Jason,1,Canada
|
||||||
|
Jonathan,1,New Zealand
|
||||||
|
Andrés,1,Ecuador
|
||||||
|
AndKitKatz,1,Estados Unidos
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(), pipeline(
|
||||||
|
r#"
|
||||||
|
echo $(open nu_times.csv)
|
||||||
|
| get name
|
||||||
|
| ^echo $it
|
||||||
|
| chop
|
||||||
|
| nth 3
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "AndKitKat");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
fn can_process_one_row_from_internal_and_pipes_it_to_stdin_of_external() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
@ -107,9 +175,7 @@ mod parse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod tilde_expansion {
|
mod tilde_expansion {
|
||||||
use nu_test_support::fs::Stub::EmptyFile;
|
use nu_test_support::nu;
|
||||||
use nu_test_support::playground::Playground;
|
|
||||||
use nu_test_support::{nu, pipeline};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
@ -138,40 +204,4 @@ mod tilde_expansion {
|
|||||||
|
|
||||||
assert_eq!(actual.out, "1~1");
|
assert_eq!(actual.out, "1~1");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn proper_it_expansion() {
|
|
||||||
Playground::setup("ls_test_1", |dirs, sandbox| {
|
|
||||||
sandbox.with_files(vec![
|
|
||||||
EmptyFile("andres.txt"),
|
|
||||||
EmptyFile("gedge.txt"),
|
|
||||||
EmptyFile("jonathan.txt"),
|
|
||||||
EmptyFile("yehuda.txt"),
|
|
||||||
]);
|
|
||||||
|
|
||||||
let actual = nu!(
|
|
||||||
cwd: dirs.test(), pipeline(
|
|
||||||
r#"
|
|
||||||
ls | sort-by name | group-by type | each { get File.name | echo $it } | to json
|
|
||||||
"#
|
|
||||||
));
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
actual.out,
|
|
||||||
r#"["andres.txt","gedge.txt","jonathan.txt","yehuda.txt"]"#
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn argument_invocation() {
|
|
||||||
let actual = nu!(
|
|
||||||
cwd: ".",
|
|
||||||
r#"
|
|
||||||
echo "foo" | echo $(echo $it)
|
|
||||||
"#
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(actual.out, "foo");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user