diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/modelica_ast.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/modelica_ast.rs b/tests/modelica_ast.rs index b6233f3..d39615e 100644 --- a/tests/modelica_ast.rs +++ b/tests/modelica_ast.rs @@ -54,3 +54,25 @@ fn test_eqn_identifiers() { Box::new(Ident("z".to_string()))), }.identifiers())); } + +#[test] +fn test_rebalance_for() { + use modelthing::modelica_ast::Expr::*; + + // z = a - 1.2345 + // a = z + 1.2345 + let done = SimpleEquation{ + lhs: Ident("z".to_string()), + rhs: BinExpr(BinOperator::Subtract, + Box::new(Ident("a".to_string())), + Box::new(Float(1.2345)))}; + assert_eq!(done, + done.rebalance_for("z".to_string()).unwrap()); + assert_eq!(SimpleEquation{ + lhs: Ident("a".to_string()), + rhs: BinExpr(BinOperator::Add, + Box::new(Ident("z".to_string())), + Box::new(Float(1.2345)))}, + done.rebalance_for("a".to_string()).unwrap()); + +} |