mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 15:13:01 +01:00
support raw strings in match patterns (#14573)
Fixes #14554 # User-Facing Changes Raw strings are now supported in match patterns: ```diff match "foo" { r#'foo'# => true, _ => false } -false +true ```
This commit is contained in:
parent
0b96962157
commit
49f377688a
@ -140,6 +140,15 @@ fn match_constant_7() {
|
||||
assert_eq!(actual.out, "success");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_constant_8() {
|
||||
let actual =
|
||||
nu!(r#"match "foo" { r#'foo'# => { print "success" }, _ => { print "failure" } }"#);
|
||||
// Make sure we don't see any of these values in the output
|
||||
// As we do not auto-print loops anymore
|
||||
assert_eq!(actual.out, "success");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_null() {
|
||||
let actual = nu!(r#"match null { null => { print "success"}, _ => { print "failure" }}"#);
|
||||
|
@ -128,7 +128,7 @@ impl Matcher for Pattern {
|
||||
false
|
||||
}
|
||||
}
|
||||
Expr::String(x) => {
|
||||
Expr::String(x) | Expr::RawString(x) => {
|
||||
if let Value::String { val, .. } = &value {
|
||||
x == val
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user