Project

General

Profile

Actions

Bug #7555

closed

unable to create constraint-related jUnit tests including unused variables

Added by Sergey Smolov over 7 years ago. Updated about 6 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).

Actions #1

Updated by Andrei Tatarnikov over 6 years ago

  • Status changed from New to Resolved
Actions #2

Updated by Sergey Smolov over 6 years ago

  • Status changed from Resolved to Verified
Actions #3

Updated by Andrei Tatarnikov over 6 years ago

Actions #4

Updated by Andrei Tatarnikov about 6 years ago

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

Also available in: Atom PDF