mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Add "fall-through" signatures (#7527)
Fixes https://github.com/nushell/nushell/issues/4659 Fixes https://github.com/nushell/nushell/issues/5294 Fixes https://github.com/nushell/nushell/issues/6124 fix https://github.com/nushell/nushell/issues/5103
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
use crate::tests::{fail_test, run_test_contains, TestResult};
|
||||
use crate::tests::{fail_test, run_test, run_test_contains, TestResult};
|
||||
|
||||
// cargo version prints a string of the form:
|
||||
// cargo 1.60.0 (d1fd9fe2c 2022-03-01)
|
||||
@ -10,10 +10,7 @@ fn known_external_runs() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn known_external_unknown_flag() -> TestResult {
|
||||
fail_test(
|
||||
r#"extern "cargo version" []; cargo version --no-such-flag"#,
|
||||
"command doesn't have flag",
|
||||
)
|
||||
run_test_contains(r#"extern "cargo" []; cargo --version"#, "cargo")
|
||||
}
|
||||
|
||||
/// GitHub issues #5179, #4618
|
||||
@ -33,3 +30,49 @@ fn known_external_subcommand_alias() -> TestResult {
|
||||
"cargo",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_complex_unknown_args() -> TestResult {
|
||||
run_test_contains(
|
||||
"extern echo []; echo foo -b -as -9 --abc -- -Dxmy=AKOO - bar",
|
||||
"foo -b -as -9 --abc -- -Dxmy=AKOO - bar",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_batched_short_flag_arg_disallowed() -> TestResult {
|
||||
fail_test(
|
||||
"extern echo [-a, -b: int]; echo -ab 10",
|
||||
"short flag batches",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_missing_positional() -> TestResult {
|
||||
fail_test("extern echo [a]; echo", "missing_positional")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_type_mismatch() -> TestResult {
|
||||
fail_test("extern echo [a: int]; echo 1.234", "mismatch")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_missing_flag_param() -> TestResult {
|
||||
fail_test(
|
||||
"extern echo [--foo: string]; echo --foo",
|
||||
"missing_flag_param",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn known_external_misc_values() -> TestResult {
|
||||
run_test(
|
||||
r#"
|
||||
let x = 'abc'
|
||||
extern echo []
|
||||
echo $x [ a b c ]
|
||||
"#,
|
||||
"abc a b c",
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user