mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 17:03:45 +01:00
Check plugin str flags are wired properly when configuring.
This commit is contained in:
parent
81d796472a
commit
832c329363
@ -23,17 +23,14 @@ impl Str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn actions(&self) -> Vec<bool> {
|
||||||
|
vec![self.downcase, self.upcase, self.int]
|
||||||
|
}
|
||||||
|
|
||||||
fn actions_desired(&self) -> u8 {
|
fn actions_desired(&self) -> u8 {
|
||||||
[self.downcase, self.upcase, self.int].iter().fold(
|
self.actions()
|
||||||
0,
|
.iter()
|
||||||
|acc, &field| {
|
.fold(0, |acc, &field| if field { acc + 1 } else { acc })
|
||||||
if field {
|
|
||||||
acc + 1
|
|
||||||
} else {
|
|
||||||
acc
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid(&self) -> bool {
|
fn is_valid(&self) -> bool {
|
||||||
@ -267,6 +264,17 @@ mod tests {
|
|||||||
record.into_spanned_value()
|
record.into_spanned_value()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn str_plugin_configuration_flags_wired() {
|
||||||
|
let mut strutils = Str::new();
|
||||||
|
|
||||||
|
let config = strutils.config().unwrap();
|
||||||
|
|
||||||
|
for action_flag in &["downcase", "upcase", "to-int"] {
|
||||||
|
assert!(config.named.get(*action_flag).is_some());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn str_accepts_downcase() {
|
fn str_accepts_downcase() {
|
||||||
let mut strutils = Str::new();
|
let mut strutils = Str::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user