tests: add shorthand, unary_operators
This commit is contained in:
parent
ee18ae3222
commit
6b33b5569d
1 changed files with 12 additions and 1 deletions
|
|
@ -1,9 +1,20 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use rug::Float;
|
||||
use rug::{Float, ops::CompleteRound};
|
||||
|
||||
use crate::nodes::{Function, Node, Nodes, Operator, PREC};
|
||||
|
||||
/// shorthand for testing the final output of tylc
|
||||
fn num(s: &str) -> Float {
|
||||
Float::parse(s).unwrap().complete(PREC)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unary_operators() {
|
||||
assert_eq!(Nodes::from_str("-10").unwrap().evaluate(), num("-10"));
|
||||
assert_eq!(Nodes::from_str("+10").unwrap().evaluate(), num("+10"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nodes_to_num() {
|
||||
assert_eq!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue