mirror of
https://github.com/nushell/nushell
synced 2025-01-14 14:14:13 +00:00
Implement PartialEq for ReturnSuccess (#3888)
This makes ReturnValue and ReturnSuccess usable in assert_eq!.
This commit is contained in:
parent
55acdaaf8c
commit
7dcc08985c
2 changed files with 14 additions and 3 deletions
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// Specifies a path to a configuration file and its type
|
/// Specifies a path to a configuration file and its type
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub enum ConfigPath {
|
pub enum ConfigPath {
|
||||||
/// Path to the global configuration file
|
/// Path to the global configuration file
|
||||||
Global(PathBuf),
|
Global(PathBuf),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use nu_source::{DbgDocBldr, DebugDocBuilder, PrettyDebug};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command itself.
|
/// The inner set of actions for the command processor. Each denotes a way to change state in the processor without changing it directly from the command itself.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum CommandAction {
|
pub enum CommandAction {
|
||||||
/// Change to a new directory or path (in non-filesystem situations)
|
/// Change to a new directory or path (in non-filesystem situations)
|
||||||
ChangePath(String),
|
ChangePath(String),
|
||||||
|
@ -63,7 +63,7 @@ impl PrettyDebug for CommandAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The fundamental success type in the pipeline. Commands return these values as their main responsibility
|
/// The fundamental success type in the pipeline. Commands return these values as their main responsibility
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum ReturnSuccess {
|
pub enum ReturnSuccess {
|
||||||
/// A value to be used or shown to the user
|
/// A value to be used or shown to the user
|
||||||
Value(Value),
|
Value(Value),
|
||||||
|
@ -123,3 +123,14 @@ impl ReturnSuccess {
|
||||||
Ok(ReturnSuccess::Action(input))
|
Ok(ReturnSuccess::Action(input))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{ReturnSuccess, ReturnValue, UntaggedValue};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn return_value_can_be_used_in_assert_eq() {
|
||||||
|
let v: ReturnValue = ReturnSuccess::value(UntaggedValue::nothing());
|
||||||
|
assert_eq!(v, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue