Project

General

Profile

Bug #7555

unable to create constraint-related jUnit tests including unused variables

Added by Sergey Smolov about 4 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
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).

History

#1

Updated by Andrei Tatarnikov about 3 years ago

  • Status changed from New to Resolved
#2

Updated by Sergey Smolov about 3 years ago

  • Status changed from Resolved to Verified
#3

Updated by Andrei Tatarnikov about 3 years ago

#4

Updated by Andrei Tatarnikov over 2 years ago

  • Published in build set to 0.4.28
  • Status changed from Verified to Closed

Also available in: Atom PDF