mirror of
https://github.com/nushell/nushell.git
synced 2026-11-27 03:55:38 +08:00
@@ -4035,11 +4035,13 @@ pub fn parse_row_condition(working_set: &mut StateWorkingSet, spans: &[Span]) ->
|
||||
Expr::FullCellPath(ref box_fcp) if box_fcp.head.as_var().is_some_and(|id| id != var_id) => {
|
||||
let mut expression = expression;
|
||||
expression.ty = Type::Any;
|
||||
working_set.exit_scope();
|
||||
return expression;
|
||||
}
|
||||
Expr::Var(arg_var_id) if arg_var_id != var_id => {
|
||||
let mut expression = expression;
|
||||
expression.ty = Type::Any;
|
||||
working_set.exit_scope();
|
||||
return expression;
|
||||
}
|
||||
_ => {
|
||||
@@ -4050,6 +4052,7 @@ pub fn parse_row_condition(working_set: &mut StateWorkingSet, spans: &[Span]) ->
|
||||
expression.ty.clone(),
|
||||
expression.span,
|
||||
));
|
||||
working_set.exit_scope();
|
||||
return Expression::garbage(working_set, expression.span);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use nu_test_support::fs::Stub::{FileWithContent, FileWithContentToBeTrimmed};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::prelude::{Result, TestResultExt, test};
|
||||
use nu_test_support::{nu, nu_repl_code};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
@@ -136,6 +137,38 @@ fn module_public_import_alias() {
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_public_import_decl_with_stored_where_condition() -> Result {
|
||||
Playground::setup(
|
||||
"module_public_import_decl_with_stored_where_condition",
|
||||
|dirs, sandbox| -> Result {
|
||||
sandbox.with_files(&[FileWithContentToBeTrimmed(
|
||||
"main.nu",
|
||||
"
|
||||
export use mod.nu helper
|
||||
",
|
||||
)]);
|
||||
|
||||
sandbox.with_files(&[FileWithContentToBeTrimmed(
|
||||
"mod.nu",
|
||||
r#"
|
||||
export def helper [] {
|
||||
let cond = {|x| true }
|
||||
[{a: 1}] | where $cond
|
||||
}
|
||||
|
||||
export def main [] { "ok" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
test()
|
||||
.cwd(dirs.test())
|
||||
.run("use main.nu helper; helper | to nuon --raw")
|
||||
.expect_value_eq("[[a];[1]]")
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_nested_imports() {
|
||||
Playground::setup("module_nested_imports", |dirs, sandbox| {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use nu_test_support::fs::Stub::{FileWithContent, FileWithContentToBeTrimmed};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::prelude::{Result, TestResultExt, test};
|
||||
use nu_test_support::{nu, nu_repl_code};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -230,6 +231,32 @@ fn add_overlay_from_const_module_name_decl() {
|
||||
assert_eq!(actual.out, "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_overlay_from_file_with_stored_where_condition() -> Result {
|
||||
Playground::setup(
|
||||
"add_overlay_from_file_with_stored_where_condition",
|
||||
|dirs, sandbox| -> Result {
|
||||
sandbox.with_files(&[FileWithContentToBeTrimmed(
|
||||
"mod.nu",
|
||||
r#"
|
||||
export def helper [] {
|
||||
let cond = {|x| true }
|
||||
[{a: 1}] | where $cond
|
||||
}
|
||||
|
||||
export def main [] { "ok" }
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let inp = &["overlay use mod.nu", "helper | to nuon --raw"];
|
||||
|
||||
let mut tester = test().cwd(dirs.test()).add_nu_to_path();
|
||||
tester.run(inp.join("; ")).expect_value_eq("[[a];[1]]")?;
|
||||
tester.run(nu_repl_code(inp)).expect_value_eq("[[a];[1]]")
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_overlay_from_const_name() {
|
||||
let inp = &[
|
||||
|
||||
Reference in New Issue
Block a user