Added -j flag to 'complete' for completing job names/pids
This commit is contained in:
@@ -9,7 +9,13 @@ use super::*;
|
||||
#[test]
|
||||
fn simple_expansion() {
|
||||
let varsub = "$foo";
|
||||
write_vars(|v| v.set_var("foo", VarKind::Str("this is the value of the variable".into()), VarFlags::NONE));
|
||||
write_vars(|v| {
|
||||
v.set_var(
|
||||
"foo",
|
||||
VarKind::Str("this is the value of the variable".into()),
|
||||
VarFlags::NONE,
|
||||
)
|
||||
});
|
||||
|
||||
let mut tokens: Vec<Tk> = LexStream::new(Arc::new(varsub.to_string()), LexFlags::empty())
|
||||
.map(|tk| tk.unwrap())
|
||||
@@ -308,7 +314,10 @@ fn dquote_escape_dollar() {
|
||||
fn dquote_escape_backslash() {
|
||||
// "\\" in double quotes should produce a single backslash
|
||||
let result = unescape_str(r#""\\""#);
|
||||
let inner: String = result.chars().filter(|&c| c != markers::DUB_QUOTE).collect();
|
||||
let inner: String = result
|
||||
.chars()
|
||||
.filter(|&c| c != markers::DUB_QUOTE)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
inner, "\\",
|
||||
"Double backslash should produce single backslash"
|
||||
@@ -319,7 +328,10 @@ fn dquote_escape_backslash() {
|
||||
fn dquote_escape_quote() {
|
||||
// "\"" should produce a literal double quote
|
||||
let result = unescape_str(r#""\"""#);
|
||||
let inner: String = result.chars().filter(|&c| c != markers::DUB_QUOTE).collect();
|
||||
let inner: String = result
|
||||
.chars()
|
||||
.filter(|&c| c != markers::DUB_QUOTE)
|
||||
.collect();
|
||||
assert!(
|
||||
inner.contains('"'),
|
||||
"Escaped quote should produce literal quote"
|
||||
@@ -330,7 +342,10 @@ fn dquote_escape_quote() {
|
||||
fn dquote_escape_backtick() {
|
||||
// "\`" should strip backslash, produce literal backtick
|
||||
let result = unescape_str(r#""\`""#);
|
||||
let inner: String = result.chars().filter(|&c| c != markers::DUB_QUOTE).collect();
|
||||
let inner: String = result
|
||||
.chars()
|
||||
.filter(|&c| c != markers::DUB_QUOTE)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
inner, "`",
|
||||
"Escaped backtick should produce literal backtick"
|
||||
@@ -341,7 +356,10 @@ fn dquote_escape_backtick() {
|
||||
fn dquote_escape_nonspecial_preserves_backslash() {
|
||||
// "\a" inside double quotes should preserve the backslash (a is not special)
|
||||
let result = unescape_str(r#""\a""#);
|
||||
let inner: String = result.chars().filter(|&c| c != markers::DUB_QUOTE).collect();
|
||||
let inner: String = result
|
||||
.chars()
|
||||
.filter(|&c| c != markers::DUB_QUOTE)
|
||||
.collect();
|
||||
assert_eq!(
|
||||
inner, "\\a",
|
||||
"Backslash before non-special char should be preserved"
|
||||
@@ -362,10 +380,16 @@ fn dquote_unescaped_dollar_expands() {
|
||||
fn dquote_mixed_escapes() {
|
||||
// "hello \$world \\end" should have literal $, single backslash
|
||||
let result = unescape_str(r#""hello \$world \\end""#);
|
||||
assert!(!result.contains(markers::VAR_SUB), "Escaped $ should not expand");
|
||||
assert!(
|
||||
!result.contains(markers::VAR_SUB),
|
||||
"Escaped $ should not expand"
|
||||
);
|
||||
assert!(result.contains('$'), "Literal $ should be in output");
|
||||
// Should have exactly one backslash (from \\)
|
||||
let inner: String = result.chars().filter(|&c| c != markers::DUB_QUOTE).collect();
|
||||
let inner: String = result
|
||||
.chars()
|
||||
.filter(|&c| c != markers::DUB_QUOTE)
|
||||
.collect();
|
||||
let backslash_count = inner.chars().filter(|&c| c == '\\').count();
|
||||
assert_eq!(backslash_count, 1, "\\\\ should produce one backslash");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user