From 6b33b5569d4fcdf5f31e94e9253a0f9cc31ad465 Mon Sep 17 00:00:00 2001 From: electria Date: Wed, 15 Jul 2026 21:54:26 -0700 Subject: [PATCH] tests: add shorthand, unary_operators --- src/nodes/tests.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nodes/tests.rs b/src/nodes/tests.rs index 022f343..c6c8b91 100644 --- a/src/nodes/tests.rs +++ b/src/nodes/tests.rs @@ -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!(