tests: add shorthand, unary_operators

This commit is contained in:
electria 2026-07-15 21:54:26 -07:00
commit 6b33b5569d
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -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!(