mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 13:06:08 +02:00
Hide alias (#4432)
* Add alias interning Now, AliasId is used to reference aliases stored in EngineState, similar to decls, blocks, etc. * Fix wrong message * Fix using decl instead of alias * Extend also alias id visibility * Merge also aliases from delta * Add alias hiding code Does not work yet but passes tests at least. * Fix wrong alias lookup and visibility appending * Add hide alias tests * Fmt & Clippy * Fix random clippy warnings in "which" command
This commit is contained in:
@ -9,6 +9,14 @@ fn hides_def() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; hide foo; foo"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_env() -> TestResult {
|
||||
fail_test(r#"let-env foo = "foo"; hide foo; $env.foo"#, "did you mean")
|
||||
@ -24,6 +32,14 @@ fn hides_def_then_redefines() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_then_redefines() -> TestResult {
|
||||
run_test(
|
||||
r#"alias foo = echo "foo"; hide foo; alias foo = echo "foo"; foo"#,
|
||||
"foo",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_env_then_redefines() -> TestResult {
|
||||
run_test(
|
||||
@ -64,6 +80,38 @@ fn hides_def_in_scope_4() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_in_scope_1() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; do { hide foo; foo }"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_in_scope_2() -> TestResult {
|
||||
run_test(
|
||||
r#"alias foo = echo "foo"; do { alias foo = echo "bar"; hide foo; foo }"#,
|
||||
"foo",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_in_scope_3() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; do { hide foo; alias foo = echo "bar"; hide foo; foo }"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_in_scope_4() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; do { alias foo = echo "bar"; hide foo; hide foo; foo }"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_env_in_scope_1() -> TestResult {
|
||||
fail_test(
|
||||
@ -104,6 +152,14 @@ fn hide_def_twice_not_allowed() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hide_alias_twice_not_allowed() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; hide foo; hide foo"#,
|
||||
"did not find",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hide_env_twice_not_allowed() -> TestResult {
|
||||
fail_test(r#"let-env foo = "foo"; hide foo; hide foo"#, "did not find")
|
||||
@ -125,6 +181,38 @@ fn hides_def_runs_env_2() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_runs_def_1() -> TestResult {
|
||||
run_test(
|
||||
r#"def foo [] { "bar" }; alias foo = echo "foo"; hide foo; foo"#,
|
||||
"bar",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_runs_def_2() -> TestResult {
|
||||
run_test(
|
||||
r#"alias foo = echo "foo"; def foo [] { "bar" }; hide foo; foo"#,
|
||||
"bar",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_runs_env_1() -> TestResult {
|
||||
run_test(
|
||||
r#"let-env foo = "bar"; alias foo = echo "foo"; hide foo; $env.foo"#,
|
||||
"bar",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_runs_env_2() -> TestResult {
|
||||
run_test(
|
||||
r#"alias foo = echo "foo"; let-env foo = "bar"; hide foo; $env.foo"#,
|
||||
"bar",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_def_and_env() -> TestResult {
|
||||
fail_test(
|
||||
@ -133,6 +221,30 @@ fn hides_def_and_env() -> TestResult {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_and_def() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; def foo [] { "bar" }; hide foo; hide foo; foo"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_def_and_env_1() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; def foo [] { "foo" }; let-env foo = "bar"; hide foo; hide foo; hide foo; $env.foo"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_alias_def_and_env_2() -> TestResult {
|
||||
fail_test(
|
||||
r#"alias foo = echo "foo"; def foo [] { "foo" }; let-env foo = "bar"; hide foo; hide foo; hide foo; foo"#,
|
||||
"", // we just care if it errors
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hides_def_import_1() -> TestResult {
|
||||
fail_test(
|
||||
|
Reference in New Issue
Block a user