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).
Updated by Andrei Tatarnikov about 7 years ago
- Status changed from New to Resolved
Updated by Sergey Smolov about 7 years ago
- Status changed from Resolved to Verified
Updated by Andrei Tatarnikov about 7 years ago
Fixed in: b87666be35fe8c275d0905c06d32ea3d5dc2b2a2
Updated by Andrei Tatarnikov almost 7 years ago
- Status changed from Verified to Closed
- Published in build set to 0.4.28
Actions