refactor: create submodules for tests
This commit is contained in:
parent
00dfcdb10c
commit
bb985f917a
2 changed files with 74 additions and 66 deletions
|
|
@ -192,12 +192,13 @@ impl Function {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use super::PREC;
|
mod tests {
|
||||||
#[cfg(test)]
|
use super::super::PREC;
|
||||||
use std::assert_matches;
|
use super::*;
|
||||||
|
use std::assert_matches;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn basic() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Nodes(vec![
|
Nodes(vec![
|
||||||
Node::Function(Function::Sine),
|
Node::Function(Function::Sine),
|
||||||
|
|
@ -212,12 +213,13 @@ fn test() {
|
||||||
.to_f64(),
|
.to_f64(),
|
||||||
1.9092974268256817,
|
1.9092974268256817,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_zerosized() {
|
fn zerosized() {
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
Nodes(vec![Node::ParenthesisStart, Node::ParenthesisEnd]).evaluate(),
|
Nodes(vec![Node::ParenthesisStart, Node::ParenthesisEnd]).evaluate(),
|
||||||
Err(Error::CollapseFailed(Nodes(v))) if v.is_empty()
|
Err(Error::CollapseFailed(Nodes(v))) if v.is_empty()
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,8 +195,12 @@ impl FromStr for Nodes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[cfg(test)]
|
||||||
fn test() {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn basic() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Nodes::from_str("sin(2) + 1").unwrap().as_ref(),
|
Nodes::from_str("sin(2) + 1").unwrap().as_ref(),
|
||||||
&[
|
&[
|
||||||
|
|
@ -208,9 +212,10 @@ fn test() {
|
||||||
Node::from(1),
|
Node::from(1),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[test]
|
|
||||||
fn test_e() {
|
#[test]
|
||||||
|
fn e_constant() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Nodes::from_str("5e * 5").unwrap().as_ref(),
|
Nodes::from_str("5e * 5").unwrap().as_ref(),
|
||||||
&[
|
&[
|
||||||
|
|
@ -221,9 +226,9 @@ fn test_e() {
|
||||||
Node::from(5),
|
Node::from(5),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unary_op() {
|
fn unary_op() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Nodes::from_str("5(-5)").unwrap().as_ref(),
|
Nodes::from_str("5(-5)").unwrap().as_ref(),
|
||||||
&[
|
&[
|
||||||
|
|
@ -234,4 +239,5 @@ fn test_unary_op() {
|
||||||
Node::ParenthesisEnd,
|
Node::ParenthesisEnd,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue