aboutsummaryrefslogtreecommitdiffstats
path: root/tests/rebalance.rs
blob: 3303a89a0b19642661a346138a2d05915aa5ff8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

extern crate modelica_parser;
extern crate modelthing;

use modelthing::modelica_model::SimpleEquationExt;
use modelica_parser::*;

#[test]
fn test_rebalance_for() {
    use modelica_parser::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());

}