Add --env and --wrapped flags to def (#10566)

This commit is contained in:
Jakub Žádník
2023-10-02 21:13:31 +03:00
committed by GitHub
parent 0d367af24a
commit eb6870cab5
20 changed files with 385 additions and 191 deletions

View File

@ -189,7 +189,7 @@ fn let_sees_in_variable2() -> TestResult {
#[test]
fn def_env() -> TestResult {
run_test(
r#"def-env bob [] { $env.BAR = "BAZ" }; bob; $env.BAR"#,
r#"def --env bob [] { $env.BAR = "BAZ" }; bob; $env.BAR"#,
"BAZ",
)
}
@ -202,7 +202,7 @@ fn not_def_env() -> TestResult {
#[test]
fn def_env_hiding_something() -> TestResult {
fail_test(
r#"$env.FOO = "foo"; def-env bob [] { hide-env FOO }; bob; $env.FOO"#,
r#"$env.FOO = "foo"; def --env bob [] { hide-env FOO }; bob; $env.FOO"#,
"",
)
}
@ -210,7 +210,7 @@ fn def_env_hiding_something() -> TestResult {
#[test]
fn def_env_then_hide() -> TestResult {
fail_test(
r#"def-env bob [] { $env.BOB = "bob" }; def-env un-bob [] { hide-env BOB }; bob; un-bob; $env.BOB"#,
r#"def --env bob [] { $env.BOB = "bob" }; def --env un-bob [] { hide-env BOB }; bob; un-bob; $env.BOB"#,
"",
)
}
@ -218,7 +218,7 @@ fn def_env_then_hide() -> TestResult {
#[test]
fn export_def_env() -> TestResult {
run_test(
r#"module foo { export def-env bob [] { $env.BAR = "BAZ" } }; use foo bob; bob; $env.BAR"#,
r#"module foo { export def --env bob [] { $env.BAR = "BAZ" } }; use foo bob; bob; $env.BAR"#,
"BAZ",
)
}

View File

@ -53,20 +53,6 @@ fn known_external_from_module() -> TestResult {
)
}
#[test]
fn known_external_wrapped_from_module() -> TestResult {
run_test_contains(
r#"module spam {
export extern-wrapped my-echo [...rest] { ^echo $rest }
}
use spam
spam my-echo foo -b -as -9 --abc -- -Dxmy=AKOO - bar
"#,
"foo -b -as -9 --abc -- -Dxmy=AKOO - bar",
)
}
#[test]
fn known_external_short_flag_batch_arg_allowed() -> TestResult {
run_test_contains("extern echo [-a, -b: int]; echo -ab 10", "-b 10")