mirror of
https://github.com/nushell/nushell
synced 2025-01-15 22:54:16 +00:00
b47bd22b37
* remove export_env command * remove several export env usage in test code * adjust hiding relative test case * fix clippy * adjust tests * update tests * unignore these tests to expose ut failed * using `use` instead of `overlay use` in some tests * Revert "using `use` instead of `overlay use` in some tests" This reverts commit2ae24b24c3
. * Revert "adjust hiding relative test case" This reverts commit4369af6d05
. * Bring back module example * Revert "update tests" This reverts commit6ae94ef513
. * Fix tests * "Fix" a test * Remove remaining deprecated env functionality * Re-enable environment hiding for `hide` To not break virtualenv since the overlay update is not merged yet * Fix hiding env in `hide` and ignore some tests Co-authored-by: kubouch <kubouch@gmail.com>
113 lines
2.6 KiB
Rust
113 lines
2.6 KiB
Rust
use crate::tests::{fail_test, run_test, TestResult};
|
|
|
|
#[test]
|
|
fn module_def_imports_1() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export def a [] { 1 }; def b [] { 2 } }; use foo; foo a"#,
|
|
"1",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_imports_2() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export def a [] { 1 }; def b [] { 2 } }; use foo a; a"#,
|
|
"1",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_imports_3() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export def a [] { 1 }; export def b [] { 2 } }; use foo *; b"#,
|
|
"2",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_imports_4() -> TestResult {
|
|
fail_test(
|
|
r#"module foo { export def a [] { 1 }; export def b [] { 2 } }; use foo c"#,
|
|
"not find import",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_imports_5() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export def a [] { 1 }; def b [] { '2' }; export def c [] { '3' } }; use foo [a, c]; c"#,
|
|
"3",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_env_imports_1() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export-env { let-env a = '1' } }; use foo; $env.a"#,
|
|
"1",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_env_imports_2() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export-env { let-env a = '1'; let-env b = '2' } }; use foo; $env.b"#,
|
|
"2",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_env_imports_3() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export-env { let-env a = '1' }; export-env { let-env b = '2' }; export-env {let-env c = '3'} }; use foo; $env.c"#,
|
|
"3",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_and_env_imports_1() -> TestResult {
|
|
run_test(
|
|
r#"module spam { export-env { let-env foo = "foo" }; export def foo [] { "bar" } }; use spam; $env.foo"#,
|
|
"foo",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_and_env_imports_2() -> TestResult {
|
|
run_test(
|
|
r#"module spam { export-env { let-env foo = "foo" }; export def foo [] { "bar" } }; use spam foo; foo"#,
|
|
"bar",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_def_import_uses_internal_command() -> TestResult {
|
|
run_test(
|
|
r#"module foo { def b [] { 2 }; export def a [] { b } }; use foo; foo a"#,
|
|
"2",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn module_env_import_uses_internal_command() -> TestResult {
|
|
run_test(
|
|
r#"module foo { def b [] { "2" }; export-env { let-env a = b } }; use foo; $env.a"#,
|
|
"2",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn multi_word_imports() -> TestResult {
|
|
run_test(
|
|
r#"module spam { export def "foo bar" [] { 10 } }; use spam "foo bar"; foo bar"#,
|
|
"10",
|
|
)
|
|
}
|
|
|
|
#[test]
|
|
fn export_alias() -> TestResult {
|
|
run_test(
|
|
r#"module foo { export alias hi = echo hello }; use foo hi; hi"#,
|
|
"hello",
|
|
)
|
|
}
|