Add initial nu-test-support port (#913)

* Add initial nu-test-support port

* finish changing binary name

* Oops, these aren't Windows-safe tests
This commit is contained in:
JT
2022-02-02 15:59:01 -05:00
committed by GitHub
parent cbdc0e2010
commit cc1b784e3d
169 changed files with 7276 additions and 56 deletions

View File

@ -7,9 +7,7 @@ use super::{EngineState, Stack};
pub trait Command: Send + Sync + CommandClone {
fn name(&self) -> &str;
fn signature(&self) -> Signature {
Signature::new(self.name()).desc(self.usage()).filter()
}
fn signature(&self) -> Signature;
fn usage(&self) -> &str;

View File

@ -1122,6 +1122,30 @@ impl Value {
val: lhs * rhs,
span,
}),
(Value::Int { val: lhs, .. }, Value::Filesize { val: rhs, .. }) => {
Ok(Value::Filesize {
val: *lhs * *rhs,
span,
})
}
(Value::Filesize { val: lhs, .. }, Value::Int { val: rhs, .. }) => {
Ok(Value::Filesize {
val: *lhs * *rhs,
span,
})
}
(Value::Int { val: lhs, .. }, Value::Duration { val: rhs, .. }) => {
Ok(Value::Duration {
val: *lhs * *rhs,
span,
})
}
(Value::Duration { val: lhs, .. }, Value::Int { val: rhs, .. }) => {
Ok(Value::Duration {
val: *lhs * *rhs,
span,
})
}
(Value::CustomValue { val: lhs, span }, rhs) => {
lhs.operation(*span, Operator::Multiply, op, rhs)
}
@ -1220,6 +1244,26 @@ impl Value {
Err(ShellError::DivisionByZero(op))
}
}
(Value::Filesize { val: lhs, .. }, Value::Int { val: rhs, .. }) => {
if *rhs != 0 {
Ok(Value::Filesize {
val: lhs / rhs,
span,
})
} else {
Err(ShellError::DivisionByZero(op))
}
}
(Value::Duration { val: lhs, .. }, Value::Int { val: rhs, .. }) => {
if *rhs != 0 {
Ok(Value::Duration {
val: lhs / rhs,
span,
})
} else {
Err(ShellError::DivisionByZero(op))
}
}
(Value::CustomValue { val: lhs, span }, rhs) => {
lhs.operation(*span, Operator::Divide, op, rhs)
}