testing suite for dataframes (#379)

This commit is contained in:
Fernando Herrera
2021-11-29 06:50:57 +00:00
committed by GitHub
parent e07ce57423
commit ee239a0d37
17 changed files with 403 additions and 88 deletions

View File

@ -1,4 +1,4 @@
use std::fmt;
use std::{cmp::Ordering, fmt};
use crate::{ast::Operator, Category, ShellError, Span, Value};
@ -29,6 +29,9 @@ pub trait CustomValue: fmt::Debug + Send + Sync {
fn follow_path_int(&self, count: usize, span: Span) -> Result<Value, ShellError>;
fn follow_path_string(&self, column_name: String, span: Span) -> Result<Value, ShellError>;
// ordering with other value
fn partial_cmp(&self, other: &Value) -> Option<Ordering>;
// Definition of an operation between the object that implements the trait
// and another Value.
// The Operator enum is used to indicate the expected operation

View File

@ -1,5 +1,14 @@
use crate::{ShellError, Span, Value};
impl From<String> for Value {
fn from(val: String) -> Self {
Value::String {
val,
span: Span::unknown(),
}
}
}
impl From<bool> for Value {
fn from(val: bool) -> Self {
Value::Bool {

View File

@ -640,6 +640,7 @@ impl PartialOrd for Value {
(Value::Binary { val: lhs, .. }, Value::Binary { val: rhs, .. }) => {
lhs.partial_cmp(rhs)
}
(Value::CustomValue { val: lhs, .. }, rhs) => lhs.partial_cmp(rhs),
(Value::Nothing { .. }, Value::Nothing { .. }) => Some(Ordering::Equal),
(_, _) => None,
}