diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-25 23:33:20 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-25 23:33:20 -0800 |
commit | 3e3f933595f64083e41433075e66aa275af66c6c (patch) | |
tree | 4ebf1f47d98c3371cfeb3a89e5b473edd5262af3 /tests | |
parent | 14d055dcc41044061357f206fe4ed71ce61fffce (diff) | |
download | modelthing-3e3f933595f64083e41433075e66aa275af66c6c.tar.gz modelthing-3e3f933595f64083e41433075e66aa275af66c6c.zip |
basic AST substituting (finishing first stab at solve_for)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/lib.rs b/tests/lib.rs index bf28476..77359de 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -32,3 +32,20 @@ fn test_load_model_entry() { fn test_search_models() { assert_eq!(search_models(Path::new("./examples/")).len() > 1, true); } + +#[test] +fn test substitute_with() { + use modelica_parser::ast::Expr::*; + + let y = BinExpr(BinOperator::Add, + Box::new(Ident("y".to_string())), + Box::new(Ident("y".to_string()))); + let z = BinExpr(BinOperator::Add, + Box::new(Ident("z".to_string())), + Box::new(Ident("z".to_string()))); + + assert_eq!(z, + substitute_with(&y, + Ident("y".to_string()), + Ident("z".to_string()))); +} |