aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-12-01 20:25:28 -0800
committerbnewbold <bnewbold@robocracy.org>2016-12-01 20:35:31 -0800
commit91e758a6eca4cc806e34a8be5d030138b7dae910 (patch)
tree936b6652d23d7be023088d4314d849f93f461390 /tests
parent53f703416730ed277cd1b76d886d4256a0063bcb (diff)
downloadmodelthing-91e758a6eca4cc806e34a8be5d030138b7dae910.tar.gz
modelthing-91e758a6eca4cc806e34a8be5d030138b7dae910.zip
equation rebalancing
Diffstat (limited to 'tests')
-rw-r--r--tests/modelica_ast.rs22
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());
+
+}