diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-17 18:34:47 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-17 18:34:47 -0800 |
commit | 9f82aceb9fbdb42f332d68f4a423123bd0788b2c (patch) | |
tree | c082b9795be8e9e9d286c8f8f1345d22f3ec1b59 /tests/rebalance.rs | |
parent | f6364ebcac0d0a88a3cc6812fd2120c97b42cc26 (diff) | |
download | modelthing-9f82aceb9fbdb42f332d68f4a423123bd0788b2c.tar.gz modelthing-9f82aceb9fbdb42f332d68f4a423123bd0788b2c.zip |
refactor modelica parser into separate crate
Diffstat (limited to 'tests/rebalance.rs')
-rw-r--r-- | tests/rebalance.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/rebalance.rs b/tests/rebalance.rs new file mode 100644 index 0000000..f365e84 --- /dev/null +++ b/tests/rebalance.rs @@ -0,0 +1,28 @@ + +extern crate modelica_parser; +extern crate modelthing; + +use modelthing::modelica_model::SimpleEquationExt; +use modelica_parser::ast::*; + +#[test] +fn test_rebalance_for() { + use modelica_parser::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()); + +} |