make existing tests pass

This commit is contained in:
Devyn Cairns 2024-07-23 00:13:07 -07:00
parent aa6bff833b
commit 1796d6ccd4
No known key found for this signature in database
7 changed files with 23 additions and 27 deletions

View File

@ -95,13 +95,13 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() {
#[test] #[test]
fn combined_pipe_redirection() { fn combined_pipe_redirection() {
let actual = nu!("$env.FOO = hello; $env.BAR = world; nu --testbin echo_env_mixed out-err FOO BAR o+e>| complete | get stdout"); let actual = nu!("$env.FOO = 'hello'; $env.BAR = 'world'; nu --testbin echo_env_mixed out-err FOO BAR o+e>| complete | get stdout");
assert_eq!(actual.out, "helloworld"); assert_eq!(actual.out, "helloworld");
} }
#[test] #[test]
fn err_pipe_redirection() { fn err_pipe_redirection() {
let actual = let actual =
nu!("$env.FOO = hello; nu --testbin echo_env_stderr FOO e>| complete | get stdout"); nu!("$env.FOO = 'hello'; nu --testbin echo_env_stderr FOO e>| complete | get stdout");
assert_eq!(actual.out, "hello"); assert_eq!(actual.out, "hello");
} }

View File

@ -144,7 +144,7 @@ fn errors_if_attempting_to_delete_home() {
Playground::setup("rm_test_8", |dirs, _| { Playground::setup("rm_test_8", |dirs, _| {
let actual = nu!( let actual = nu!(
cwd: dirs.root(), cwd: dirs.root(),
"$env.HOME = myhome ; rm -rf ~" "$env.HOME = 'myhome' ; rm -rf ~"
); );
assert!(actual.err.contains("please use -I or -i")); assert!(actual.err.contains("please use -I or -i"));

View File

@ -2567,7 +2567,7 @@ fn theme_cmd(theme: &str, footer: bool, then: &str) -> String {
with_footer = "$env.config.footer_mode = \"always\"".to_string(); with_footer = "$env.config.footer_mode = \"always\"".to_string();
} }
format!("$env.config.table.mode = {theme}; $env.config.table.header_on_separator = true; {with_footer}; {then}") format!("$env.config.table.mode = \"{theme}\"; $env.config.table.header_on_separator = true; {with_footer}; {then}")
} }
#[test] #[test]

View File

@ -4855,11 +4855,11 @@ pub fn parse_assignment_expression(
} }
// Parse the lhs and operator as usual for a math expression // Parse the lhs and operator as usual for a math expression
let lhs = parse_expression(working_set, lhs_spans); let mut lhs = parse_expression(working_set, lhs_spans);
let operator = parse_assignment_operator(working_set, op_span); let mut operator = parse_assignment_operator(working_set, op_span);
// Re-parse the right-hand side as a subexpression // Re-parse the right-hand side as a subexpression
let rhs_span = Span::concat(&rhs_spans); let rhs_span = Span::concat(rhs_spans);
let (rhs_tokens, rhs_error) = lex( let (rhs_tokens, rhs_error) = lex(
working_set.get_span_contents(rhs_span), working_set.get_span_contents(rhs_span),
@ -4874,26 +4874,23 @@ pub fn parse_assignment_expression(
let rhs_block = parse_block(working_set, &rhs_tokens, rhs_span, false, true); let rhs_block = parse_block(working_set, &rhs_tokens, rhs_span, false, true);
let rhs_ty = rhs_block.output_type(); let rhs_ty = rhs_block.output_type();
let rhs_block_id = working_set.add_block(Arc::new(rhs_block)); let rhs_block_id = working_set.add_block(Arc::new(rhs_block));
let rhs = Expression::new( let mut rhs = Expression::new(
working_set, working_set,
Expr::Subexpression(rhs_block_id), Expr::Subexpression(rhs_block_id),
rhs_span, rhs_span,
rhs_ty, rhs_ty,
); );
if !type_compatible(&lhs.ty, &rhs.ty) { let (result_ty, err) = math_result_type(working_set, &mut lhs, &mut operator, &mut rhs);
working_set.parse_errors.push(ParseError::TypeMismatch( if let Some(err) = err {
lhs.ty.clone(), working_set.parse_errors.push(err);
rhs.ty.clone(),
rhs_span,
));
} }
Expression::new( Expression::new(
working_set, working_set,
Expr::BinaryOp(Box::new(lhs), Box::new(operator), Box::new(rhs)), Expr::BinaryOp(Box::new(lhs), Box::new(operator), Box::new(rhs)),
expr_span, expr_span,
Type::Nothing, result_ty,
) )
} }

View File

@ -1142,18 +1142,17 @@ fn test_nothing_comparison_eq() {
#[rstest] #[rstest]
#[case(b"let a = 1 err> /dev/null")] #[case(b"let a = 1 err> /dev/null")]
#[case(b"let a = 1 out> /dev/null")] #[case(b"let a = 1 out> /dev/null")]
#[case(b"mut a = 1 err> /dev/null")]
#[case(b"mut a = 1 out> /dev/null")]
#[case(b"let a = 1 out+err> /dev/null")] #[case(b"let a = 1 out+err> /dev/null")]
#[case(b"mut a = 1 out+err> /dev/null")] fn test_redirection_with_let(#[case] phase: &[u8]) {
fn test_redirection_with_letmut(#[case] phase: &[u8]) {
let engine_state = EngineState::new(); let engine_state = EngineState::new();
let mut working_set = StateWorkingSet::new(&engine_state); let mut working_set = StateWorkingSet::new(&engine_state);
working_set.add_decl(Box::new(Let));
let _block = parse(&mut working_set, None, phase, true); let _block = parse(&mut working_set, None, phase, true);
assert!(matches!( assert!(
working_set.parse_errors.first(), working_set.parse_errors.is_empty(),
Some(ParseError::RedirectingBuiltinCommand(_, _, _)) "parse errors: {:?}",
)); working_set.parse_errors
);
} }
#[rstest] #[rstest]

View File

@ -6,9 +6,9 @@ fn get_env_by_name() {
cwd: ".", cwd: ".",
plugin: ("nu_plugin_example"), plugin: ("nu_plugin_example"),
r#" r#"
$env.FOO = bar $env.FOO = 'bar'
example env FOO | print example env FOO | print
$env.FOO = baz $env.FOO = 'baz'
example env FOO | print example env FOO | print
"# "#
); );
@ -21,7 +21,7 @@ fn get_envs() {
let result = nu_with_plugins!( let result = nu_with_plugins!(
cwd: ".", cwd: ".",
plugin: ("nu_plugin_example"), plugin: ("nu_plugin_example"),
"$env.BAZ = foo; example env | get BAZ" "$env.BAZ = 'foo'; example env | get BAZ"
); );
assert!(result.status.success()); assert!(result.status.success());
assert_eq!("foo", result.out); assert_eq!("foo", result.out);

View File

@ -20,7 +20,7 @@ fn mutate_nu_config_nested_ls() -> TestResult {
fn mutate_nu_config_nested_table() -> TestResult { fn mutate_nu_config_nested_table() -> TestResult {
run_test_std( run_test_std(
r#" r#"
$env.config.table.trim.methodology = wrapping $env.config.table.trim.methodology = 'wrapping'
$env.config.table.trim.wrapping_try_keep_words = false $env.config.table.trim.wrapping_try_keep_words = false
$env.config.table.trim.wrapping_try_keep_words $env.config.table.trim.wrapping_try_keep_words
"#, "#,