str-expand: update bracoxide to v0.1.2, fixes #9913 (#9940)

Fixes: #9913 

Changes:

- updated crate bracoxide from v0.1.1 to v0.1.2
This commit is contained in:
A. Taha Baki 2023-08-07 22:40:38 +03:00 committed by GitHub
parent a2e117f8b0
commit d302d63030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 1 deletions

View File

@ -93,7 +93,7 @@ url = "2.2"
uuid = { version = "1.3", features = ["v4"] }
wax = { version = "0.5" }
which = { version = "4.4", optional = true }
bracoxide = "0.1.1"
bracoxide = "0.1.2"
[target.'cfg(windows)'.dependencies]
winreg = "0.50"

View File

@ -65,6 +65,18 @@ impl Command for SubCommand {
},)
},
Example {
description: "Commas that are not inside any braces need to be skipped.",
example: "'Welcome\\, {home,mon ami}!' | str expand",
result: Some(Value::List{
vals: vec![
Value::test_string("Welcome, home!"),
Value::test_string("Welcome, mon ami!"),
],
span: Span::test_data()
},)
},
Example {
description: "Use double backslashes to add a backslash.",
example: "'A{B\\\\,C}' | str expand",
@ -270,6 +282,59 @@ fn str_expand(contents: &str, span: Span, value_span: Span) -> Value {
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn dots() {
assert_eq!(
str_expand("{a.b.c,d}", Span::test_data(), Span::test_data()),
Value::List {
vals: vec![
Value::String {
val: String::from("a.b.c"),
span: Span::test_data(),
},
Value::String {
val: String::from("d"),
span: Span::test_data(),
},
],
span: Span::test_data(),
}
);
assert_eq!(
str_expand("{1.2.3,a}", Span::test_data(), Span::test_data()),
Value::List {
vals: vec![
Value::String {
val: String::from("1.2.3"),
span: Span::test_data(),
},
Value::String {
val: String::from("a"),
span: Span::test_data(),
},
],
span: Span::test_data(),
}
);
assert_eq!(
str_expand("{a-1.2,b}", Span::test_data(), Span::test_data()),
Value::List {
vals: vec![
Value::String {
val: String::from("a-1.2"),
span: Span::test_data(),
},
Value::String {
val: String::from("b"),
span: Span::test_data(),
},
],
span: Span::test_data(),
}
);
}
#[test]
fn test_examples() {
use crate::test_examples;