make existing tests pass
This commit is contained in:
parent
aa6bff833b
commit
1796d6ccd4
|
@ -95,13 +95,13 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() {
|
|||
|
||||
#[test]
|
||||
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");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn err_pipe_redirection() {
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ fn errors_if_attempting_to_delete_home() {
|
|||
Playground::setup("rm_test_8", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.root(),
|
||||
"$env.HOME = myhome ; rm -rf ~"
|
||||
"$env.HOME = 'myhome' ; rm -rf ~"
|
||||
);
|
||||
|
||||
assert!(actual.err.contains("please use -I or -i"));
|
||||
|
|
|
@ -2567,7 +2567,7 @@ fn theme_cmd(theme: &str, footer: bool, then: &str) -> 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]
|
||||
|
|
|
@ -4855,11 +4855,11 @@ pub fn parse_assignment_expression(
|
|||
}
|
||||
|
||||
// Parse the lhs and operator as usual for a math expression
|
||||
let lhs = parse_expression(working_set, lhs_spans);
|
||||
let operator = parse_assignment_operator(working_set, op_span);
|
||||
let mut lhs = parse_expression(working_set, lhs_spans);
|
||||
let mut operator = parse_assignment_operator(working_set, op_span);
|
||||
|
||||
// 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(
|
||||
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_ty = rhs_block.output_type();
|
||||
let rhs_block_id = working_set.add_block(Arc::new(rhs_block));
|
||||
let rhs = Expression::new(
|
||||
let mut rhs = Expression::new(
|
||||
working_set,
|
||||
Expr::Subexpression(rhs_block_id),
|
||||
rhs_span,
|
||||
rhs_ty,
|
||||
);
|
||||
|
||||
if !type_compatible(&lhs.ty, &rhs.ty) {
|
||||
working_set.parse_errors.push(ParseError::TypeMismatch(
|
||||
lhs.ty.clone(),
|
||||
rhs.ty.clone(),
|
||||
rhs_span,
|
||||
));
|
||||
let (result_ty, err) = math_result_type(working_set, &mut lhs, &mut operator, &mut rhs);
|
||||
if let Some(err) = err {
|
||||
working_set.parse_errors.push(err);
|
||||
}
|
||||
|
||||
Expression::new(
|
||||
working_set,
|
||||
Expr::BinaryOp(Box::new(lhs), Box::new(operator), Box::new(rhs)),
|
||||
expr_span,
|
||||
Type::Nothing,
|
||||
result_ty,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1142,18 +1142,17 @@ fn test_nothing_comparison_eq() {
|
|||
#[rstest]
|
||||
#[case(b"let a = 1 err> /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"mut a = 1 out+err> /dev/null")]
|
||||
fn test_redirection_with_letmut(#[case] phase: &[u8]) {
|
||||
fn test_redirection_with_let(#[case] phase: &[u8]) {
|
||||
let engine_state = EngineState::new();
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
working_set.add_decl(Box::new(Let));
|
||||
let _block = parse(&mut working_set, None, phase, true);
|
||||
assert!(matches!(
|
||||
working_set.parse_errors.first(),
|
||||
Some(ParseError::RedirectingBuiltinCommand(_, _, _))
|
||||
));
|
||||
assert!(
|
||||
working_set.parse_errors.is_empty(),
|
||||
"parse errors: {:?}",
|
||||
working_set.parse_errors
|
||||
);
|
||||
}
|
||||
|
||||
#[rstest]
|
||||
|
|
|
@ -6,9 +6,9 @@ fn get_env_by_name() {
|
|||
cwd: ".",
|
||||
plugin: ("nu_plugin_example"),
|
||||
r#"
|
||||
$env.FOO = bar
|
||||
$env.FOO = 'bar'
|
||||
example env FOO | print
|
||||
$env.FOO = baz
|
||||
$env.FOO = 'baz'
|
||||
example env FOO | print
|
||||
"#
|
||||
);
|
||||
|
@ -21,7 +21,7 @@ fn get_envs() {
|
|||
let result = nu_with_plugins!(
|
||||
cwd: ".",
|
||||
plugin: ("nu_plugin_example"),
|
||||
"$env.BAZ = foo; example env | get BAZ"
|
||||
"$env.BAZ = 'foo'; example env | get BAZ"
|
||||
);
|
||||
assert!(result.status.success());
|
||||
assert_eq!("foo", result.out);
|
||||
|
|
|
@ -20,7 +20,7 @@ fn mutate_nu_config_nested_ls() -> TestResult {
|
|||
fn mutate_nu_config_nested_table() -> TestResult {
|
||||
run_test_std(
|
||||
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
|
||||
"#,
|
||||
|
|
Loading…
Reference in New Issue
Block a user