mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:45:04 +02:00
fix bare interpolation regression (#16235)
Regression from #16204 Before:  After:  # Tests + Formatting +1 --------- Co-authored-by: Bahex <17417311+Bahex@users.noreply.github.com>
This commit is contained in:
@ -1636,6 +1636,46 @@ mod string {
|
||||
assert_eq!(subexprs[3], &Expr::String("bar".to_string()));
|
||||
}
|
||||
|
||||
/// PR with summary of the issue: https://github.com/nushell/nushell/pull/16235
|
||||
/// Release Notes Mention: https://www.nushell.sh/blog/2025-07-23-nushell_0_106_0.html#regression-bare-word-interpolation-on-both-sides-does-not-work-toc
|
||||
#[test]
|
||||
pub fn parse_string_interpolation_bare_starting_and_ending_subexpr() {
|
||||
let engine_state = EngineState::new();
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
|
||||
let block = parse(
|
||||
&mut working_set,
|
||||
None,
|
||||
b"(100 + 20 + 3)/bar/(300 + 20 + 1)",
|
||||
true,
|
||||
);
|
||||
|
||||
assert!(working_set.parse_errors.is_empty(),);
|
||||
|
||||
let [pipeline] = block.pipelines.as_slice() else {
|
||||
panic!("expected 1 pipeline")
|
||||
};
|
||||
let [element] = pipeline.elements.as_slice() else {
|
||||
panic!("expected 1 pipeline element")
|
||||
};
|
||||
assert!(element.redirection.is_none());
|
||||
|
||||
let Expr::StringInterpolation(expressions) = &element.expr.expr else {
|
||||
panic!("Expected an `Expr::StringInterpolation`")
|
||||
};
|
||||
let subexprs: Vec<_> = expressions.iter().map(|e| &e.expr).collect();
|
||||
|
||||
let [
|
||||
Expr::FullCellPath(..),
|
||||
Expr::String(s),
|
||||
Expr::FullCellPath(..),
|
||||
] = subexprs.as_slice()
|
||||
else {
|
||||
panic!("AST does not have the expected structure")
|
||||
};
|
||||
assert_eq!(s, "/bar/");
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn parse_string_interpolation_bare_starting_subexpr_external_arg() {
|
||||
let engine_state = EngineState::new();
|
||||
|
Reference in New Issue
Block a user