From 3e3f933595f64083e41433075e66aa275af66c6c Mon Sep 17 00:00:00 2001 From: bnewbold Date: Sun, 25 Dec 2016 23:33:20 -0800 Subject: basic AST substituting (finishing first stab at solve_for) --- tests/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') 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()))); +} -- cgit v1.2.3