2022-01-31 17:42:12 +00:00
|
|
|
use crate::tests::{fail_test, run_test, TestResult};
|
2021-12-25 19:39:42 +00:00
|
|
|
|
|
|
|
// TODO: Test the use/hide tests also as separate lines in REPL (i.e., with merging the delta in between)
|
|
|
|
#[test]
|
|
|
|
fn hides_def() -> TestResult {
|
2023-01-22 19:34:15 +00:00
|
|
|
fail_test(r#"def foo [] { "foo" }; hide foo; foo"#, "external_command")
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
2022-02-12 09:50:37 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_alias() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"alias foo = echo "foo"; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-02-12 09:50:37 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_env() -> TestResult {
|
2022-09-21 00:46:01 +00:00
|
|
|
fail_test(r#"let-env foo = "foo"; hide-env foo; $env.foo"#, "")
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_then_redefines() -> TestResult {
|
|
|
|
// this one should fail because of predecl -- cannot have more defs with the same name in a
|
|
|
|
// block
|
|
|
|
fail_test(
|
|
|
|
r#"def foo [] { "foo" }; hide foo; def foo [] { "bar" }; foo"#,
|
|
|
|
"defined more than once",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-12 09:50:37 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_alias_then_redefines() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"alias foo = echo "foo"; hide foo; alias foo = echo "foo"; foo"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_env_then_redefines() -> TestResult {
|
|
|
|
run_test(
|
2022-08-13 09:55:06 +00:00
|
|
|
r#"let-env foo = "foo"; hide-env foo; let-env foo = "bar"; $env.foo"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"bar",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_in_scope_1() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"def foo [] { "foo" }; do { hide foo; foo }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_in_scope_2() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"def foo [] { "foo" }; do { def foo [] { "bar" }; hide foo; foo }"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_in_scope_3() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"def foo [] { "foo" }; do { hide foo; def foo [] { "bar" }; hide foo; foo }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_in_scope_4() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"def foo [] { "foo" }; do { def foo [] { "bar" }; hide foo; hide foo; foo }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-12 09:50:37 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_alias_in_scope_1() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"alias foo = echo "foo"; do { hide foo; foo }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-02-12 09:50:37 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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 }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-02-12 09:50:37 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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 }"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-02-12 09:50:37 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_env_in_scope_1() -> TestResult {
|
2022-09-25 16:52:43 +00:00
|
|
|
fail_test(
|
|
|
|
r#"let-env foo = "foo"; do { hide-env foo; $env.foo }"#,
|
2022-12-10 17:23:34 +00:00
|
|
|
"not_found",
|
2022-09-25 16:52:43 +00:00
|
|
|
)
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_env_in_scope_2() -> TestResult {
|
|
|
|
run_test(
|
2022-08-13 09:55:06 +00:00
|
|
|
r#"let-env foo = "foo"; do { let-env foo = "bar"; hide-env foo; $env.foo }"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_env_in_scope_3() -> TestResult {
|
|
|
|
fail_test(
|
2022-08-13 09:55:06 +00:00
|
|
|
r#"let-env foo = "foo"; do { hide-env foo; let-env foo = "bar"; hide-env foo; $env.foo }"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_env_in_scope_4() -> TestResult {
|
|
|
|
fail_test(
|
2022-08-13 09:55:06 +00:00
|
|
|
r#"let-env foo = "foo"; do { let-env foo = "bar"; hide-env foo; hide-env foo; $env.foo }"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-03-17 22:35:50 +00:00
|
|
|
#[ignore]
|
2021-12-25 19:39:42 +00:00
|
|
|
fn hide_def_twice_not_allowed() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"def foo [] { "foo" }; hide foo; hide foo"#,
|
|
|
|
"did not find",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-12 09:50:37 +00:00
|
|
|
#[test]
|
2022-03-17 22:35:50 +00:00
|
|
|
#[ignore]
|
2022-02-12 09:50:37 +00:00
|
|
|
fn hide_alias_twice_not_allowed() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"alias foo = echo "foo"; hide foo; hide foo"#,
|
|
|
|
"did not find",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hide_env_twice_not_allowed() -> TestResult {
|
2022-09-21 00:46:01 +00:00
|
|
|
fail_test(r#"let-env foo = "foo"; hide-env foo; hide-env foo"#, "")
|
2022-08-13 09:55:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hide_env_twice_allowed() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"let-env foo = "foo"; hide-env foo; hide-env -i foo; $env.foo"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2022-08-13 09:55:06 +00:00
|
|
|
)
|
2021-12-25 19:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-25 16:52:43 +00:00
|
|
|
#[ignore = "Re-enable after virtualenv update"]
|
2021-12-25 19:39:42 +00:00
|
|
|
fn hides_def_runs_env_1() -> TestResult {
|
|
|
|
run_test(
|
2022-01-04 21:34:42 +00:00
|
|
|
r#"let-env foo = "bar"; def foo [] { "foo" }; hide foo; $env.foo"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"bar",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-25 16:52:43 +00:00
|
|
|
#[ignore = "Re-enable after virtualenv update"]
|
2021-12-25 19:39:42 +00:00
|
|
|
fn hides_def_runs_env_2() -> TestResult {
|
|
|
|
run_test(
|
2022-01-04 21:34:42 +00:00
|
|
|
r#"def foo [] { "foo" }; let-env foo = "bar"; hide foo; $env.foo"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"bar",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-12 09:50:37 +00:00
|
|
|
#[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_and_def() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"alias foo = echo "foo"; def foo [] { "bar" }; hide foo; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-02-12 09:50:37 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_def_import_1() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam; hide spam foo; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_import_2() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam; hide spam; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_import_3() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam; hide spam [foo]; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_import_4() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam foo; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_import_5() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam *; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_import_6() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam *; hide spam *; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-03-25 22:56:40 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_def_import_then_reimports() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam foo; hide foo; use spam foo; foo"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_1() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam; hide spam foo; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_2() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam; hide spam; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_3() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam; hide spam [foo]; spam foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_4() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam foo; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_5() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam *; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_6() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam *; hide spam *; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2022-03-25 22:56:40 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_alias_import_then_reimports() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"module spam { export alias foo = "foo" }; use spam foo; hide foo; use spam foo; foo"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-12-25 19:39:42 +00:00
|
|
|
#[test]
|
|
|
|
fn hides_env_import_1() -> TestResult {
|
|
|
|
fail_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "foo" } }; use spam; hide-env foo; $env.foo"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_runs_env_import() -> TestResult {
|
|
|
|
run_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "foo" }; export def foo [] { "bar" } }; use spam foo; hide foo; $env.foo"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_def_and_env_import_1() -> TestResult {
|
|
|
|
fail_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "foo" }; export def foo [] { "bar" } }; use spam foo; hide foo; hide-env foo; $env.foo"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn use_def_import_after_hide() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"module spam { export def foo [] { "foo" } }; use spam foo; hide foo; use spam foo; foo"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn use_env_import_after_hide() -> TestResult {
|
|
|
|
run_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "foo" } }; use spam; hide-env foo; use spam; $env.foo"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hide_shadowed_decl() -> TestResult {
|
|
|
|
run_test(
|
|
|
|
r#"module spam { export def foo [] { "bar" } }; def foo [] { "foo" }; do { use spam foo; hide foo; foo }"#,
|
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hide_shadowed_env() -> TestResult {
|
|
|
|
run_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "bar" } }; let-env foo = "foo"; do { use spam; hide-env foo; $env.foo }"#,
|
2021-12-25 19:39:42 +00:00
|
|
|
"foo",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_all_decls_within_scope() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def foo [] { "bar" } }; def foo [] { "foo" }; use spam foo; hide foo; foo"#,
|
2023-01-22 19:34:15 +00:00
|
|
|
"external_command",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_all_envs_within_scope() -> TestResult {
|
|
|
|
fail_test(
|
2022-09-25 16:52:43 +00:00
|
|
|
r#"module spam { export-env { let-env foo = "bar" } }; let-env foo = "foo"; use spam; hide-env foo; $env.foo"#,
|
2022-09-21 00:46:01 +00:00
|
|
|
"",
|
2021-12-25 19:39:42 +00:00
|
|
|
)
|
|
|
|
}
|
2023-01-22 19:34:15 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_main_import_1() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def main [] { "foo" } }; use spam; hide spam; spam"#,
|
|
|
|
"external_command",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_main_import_2() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def main [] { "foo" } }; use spam; hide spam main; spam"#,
|
|
|
|
"external_command",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_main_import_3() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def main [] { "foo" } }; use spam; hide spam [ main ]; spam"#,
|
|
|
|
"external_command",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn hides_main_import_4() -> TestResult {
|
|
|
|
fail_test(
|
|
|
|
r#"module spam { export def main [] { "foo" } }; use spam; hide spam *; spam"#,
|
|
|
|
"external_command",
|
|
|
|
)
|
|
|
|
}
|