Assert.assertEquals(subtract.getArg2().getVarName(), "b");
}
@Test
public void test_function_expansion_09() {
Expr takeaway = new E_Subtract(new ExprVar("x"), new ExprVar("y"));
List<Var> args = new ArrayList<Var>();
args.add(Var.alloc("x"));
args.add(Var.alloc("y"));
UserDefinedFunctionFactory.getFactory().add("http://example/takeaway", takeaway, args);
//Test that with preserveDependencies set to false (the default) that the definition is expanded appropriately
ExprList altArgs = new ExprList();
altArgs.add(new ExprVar("b"));
altArgs.add(new ExprVar("a"));
ArrayList<Var> defArgs = new ArrayList<Var>();
defArgs.add(Var.alloc("a"));
defArgs.add(Var.alloc("b"));
Expr test = new E_Function("http://example/takeaway", altArgs);
UserDefinedFunctionFactory.getFactory().add("http://example/test", test, defArgs);
UserDefinedFunctionDefinition def = UserDefinedFunctionFactory.getFactory().get("http://example/test");
Expr base = def.getBaseExpr();
Assert.assertTrue(base instanceof E_Subtract);
E_Subtract subtract = (E_Subtract)base;
Assert.assertTrue(subtract.getArg1() instanceof ExprVar);
Assert.assertTrue(subtract.getArg2() instanceof ExprVar);
Assert.assertEquals(subtract.getArg1().getVarName(), "b");
Assert.assertEquals(subtract.getArg2().getVarName(), "a");
}