mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:45:56 +02:00
Rust 1.85, edition=2024 (#15741)
This commit is contained in:
@ -882,7 +882,7 @@ impl Pattern {
|
||||
AnySequence
|
||||
if options.require_literal_separator && follows_separator =>
|
||||
{
|
||||
return SubPatternDoesntMatch
|
||||
return SubPatternDoesntMatch;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@ -1159,7 +1159,7 @@ impl Default for MatchOptions {
|
||||
mod test {
|
||||
use crate::{Paths, PatternError, Uninterruptible};
|
||||
|
||||
use super::{glob as glob_with_signals, MatchOptions, Pattern};
|
||||
use super::{MatchOptions, Pattern, glob as glob_with_signals};
|
||||
use std::path::Path;
|
||||
|
||||
fn glob(pattern: &str) -> Result<Paths, PatternError> {
|
||||
@ -1266,10 +1266,12 @@ mod test {
|
||||
})
|
||||
.unwrap();
|
||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||
assert!(glob(root_with_device.as_os_str().to_str().unwrap())
|
||||
.unwrap()
|
||||
.next()
|
||||
.is_some());
|
||||
assert!(
|
||||
glob(root_with_device.as_os_str().to_str().unwrap())
|
||||
.unwrap()
|
||||
.next()
|
||||
.is_some()
|
||||
);
|
||||
}
|
||||
win()
|
||||
}
|
||||
@ -1281,15 +1283,21 @@ mod test {
|
||||
assert!(!Pattern::new("a*b*c").unwrap().matches("abcd"));
|
||||
assert!(Pattern::new("a*b*c").unwrap().matches("a_b_c"));
|
||||
assert!(Pattern::new("a*b*c").unwrap().matches("a___b___c"));
|
||||
assert!(Pattern::new("abc*abc*abc")
|
||||
.unwrap()
|
||||
.matches("abcabcabcabcabcabcabc"));
|
||||
assert!(!Pattern::new("abc*abc*abc")
|
||||
.unwrap()
|
||||
.matches("abcabcabcabcabcabcabca"));
|
||||
assert!(Pattern::new("a*a*a*a*a*a*a*a*a")
|
||||
.unwrap()
|
||||
.matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
|
||||
assert!(
|
||||
Pattern::new("abc*abc*abc")
|
||||
.unwrap()
|
||||
.matches("abcabcabcabcabcabcabc")
|
||||
);
|
||||
assert!(
|
||||
!Pattern::new("abc*abc*abc")
|
||||
.unwrap()
|
||||
.matches("abcabcabcabcabcabcabca")
|
||||
);
|
||||
assert!(
|
||||
Pattern::new("a*a*a*a*a*a*a*a*a")
|
||||
.unwrap()
|
||||
.matches("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||
);
|
||||
assert!(Pattern::new("a*b[xyz]c*d").unwrap().matches("abxcdbxcddd"));
|
||||
}
|
||||
|
||||
@ -1480,31 +1488,47 @@ mod test {
|
||||
recursive_match_hidden_dir: true,
|
||||
};
|
||||
|
||||
assert!(Pattern::new("abc/def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal));
|
||||
assert!(!Pattern::new("abc?def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal));
|
||||
assert!(!Pattern::new("abc*def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal));
|
||||
assert!(!Pattern::new("abc[/]def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal));
|
||||
assert!(
|
||||
Pattern::new("abc/def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal)
|
||||
);
|
||||
assert!(
|
||||
!Pattern::new("abc?def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal)
|
||||
);
|
||||
assert!(
|
||||
!Pattern::new("abc*def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal)
|
||||
);
|
||||
assert!(
|
||||
!Pattern::new("abc[/]def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_require_literal)
|
||||
);
|
||||
|
||||
assert!(Pattern::new("abc/def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal));
|
||||
assert!(Pattern::new("abc?def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal));
|
||||
assert!(Pattern::new("abc*def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal));
|
||||
assert!(Pattern::new("abc[/]def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal));
|
||||
assert!(
|
||||
Pattern::new("abc/def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal)
|
||||
);
|
||||
assert!(
|
||||
Pattern::new("abc?def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal)
|
||||
);
|
||||
assert!(
|
||||
Pattern::new("abc*def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal)
|
||||
);
|
||||
assert!(
|
||||
Pattern::new("abc[/]def")
|
||||
.unwrap()
|
||||
.matches_with("abc/def", options_not_require_literal)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Reference in New Issue
Block a user