Actions
Bug #7555
closedunable to create constraint-related jUnit tests including unused variables
Start date:
09/07/2016
Due date:
% Done:
0%
Estimated time:
Detected in build:
svn
Platform:
Published in build:
0.4.28
Description
When creating a jUnit constraint-related test case I've found that the test fails because of unused variable inside my constraint.
More precisely, the problem is in this code fragment of GenericSolverTestBase
class:
private static void checkResult(CalculatorEngine calculator, Constraint constraint, SolverResult result) {
final Formulas formulas = (Formulas) constraint.getInnerRep();
final Collection<NodeVariable> variables =
ExprUtils.getVariables(formulas.exprs());
final Map<String, NodeVariable> variableMap = new HashMap<>(variables.size());
for (NodeVariable node : variables) {
variableMap.put(node.getName(), node);
}
final List<NodeBinding.BoundVariable> bindings =
new ArrayList<>(result.getVariables().size());
for (Variable var : result.getVariables()) {
final NodeVariable node = variableMap.get(var.getName());
final NodeValue value = new NodeValue(var.getData());
bindings.add(NodeBinding.bindVariable(node, value));
}
Sizes of variables
and bindings
seem to be different.
I've also implemented a small test case called UnusedVariableTestCase
that illustrates the problem (r1298).
Actions