forked from extern/nushell
Add example tests (nu-plugin-test-support) for plugins in repo (#12281)
# Description Uses the new `nu-plugin-test-support` crate to test the examples of commands provided by plugins in the repo. Also fixed some of the examples to pass. # User-Facing Changes - Examples that are more guaranteed to work # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use nu_protocol::{CustomValue, ShellError, Span, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct SecondCustomValue {
|
||||
pub(crate) something: String,
|
||||
}
|
||||
@ -59,6 +61,16 @@ impl CustomValue for SecondCustomValue {
|
||||
))
|
||||
}
|
||||
|
||||
fn partial_cmp(&self, other: &Value) -> Option<Ordering> {
|
||||
if let Value::CustomValue { val, .. } = other {
|
||||
val.as_any()
|
||||
.downcast_ref()
|
||||
.and_then(|other: &SecondCustomValue| PartialOrd::partial_cmp(self, other))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
Reference in New Issue
Block a user