boolean pass = false; try { BoxAndWhiskerCalculator.calculateQ1(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); List values = new ArrayList(); double q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertTrue(Double.isNaN(q1)); values.add(new Double(1.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.0, EPSILON); values.add(new Double(2.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.0, EPSILON); values.add(new Double(3.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.5, EPSILON); values.add(new Double(4.0)); q1 = BoxAndWhiskerCalculator.calculateQ1(values); assertEquals(q1, 1.5, EPSILON);
boolean pass = false; try { BoxAndWhiskerCalculator.calculateQ3(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); List values = new ArrayList(); double q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertTrue(Double.isNaN(q3)); values.add(new Double(1.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 1.0, EPSILON); values.add(new Double(2.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.0, EPSILON); values.add(new Double(3.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.5, EPSILON); values.add(new Double(4.0)); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 3.5, EPSILON);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.java
Method name: void testCalculateQ1() Method name: void testCalculateQ3()
Number of AST nodes: 19 Number of AST nodes: 19
1
boolean pass = false;
1
boolean pass = false;
2
        try {
2
        try {
3
            BoxAndWhiskerCalculator.calculateQ1(null);
3
            BoxAndWhiskerCalculator.calculateQ3(null);
4
        }
4
        }
5
        catch (IllegalArgumentException e) {
5
        catch (IllegalArgumentException e) {
6
            pass = true;
6
            pass = true;
7
        }
7
        }
8
        assertTrue(pass);
8
        assertTrue(pass);
9
        
10
        List values = new ArrayList();
9
        List values = new ArrayList();
11
        double q1 = BoxAndWhiskerCalculator.calculateQ1(values);
10
        double q3 = BoxAndWhiskerCalculator.calculateQ3(values);
12
        assertTrue(Double.isNaN(q1));
11
        assertTrue(Double.isNaN(q3));
13
        values.add(new Double(1.0));
12
        values.add(new Double(1.0));
14
        q1 = BoxAndWhiskerCalculator.calculateQ1(values);
13
        q3 = BoxAndWhiskerCalculator.calculateQ3(values);
15
        assertEquals(q1, 1.0, EPSILON);
14
        assertEquals(q3, 1.0, EPSILON);
16
        values.add(new Double(2.0));
15
        values.add(new Double(2.0));
17
        q1 = BoxAndWhiskerCalculator.calculateQ1(values);
16
        q3 = BoxAndWhiskerCalculator.calculateQ3(values);
18
        assertEquals(q1, 1.0, EPSILON);
17
        assertEquals(q3, 2.0, EPSILON);
19
        values.add(new Double(3.0));
18
        values.add(new Double(3.0));
20
        q1 = BoxAndWhiskerCalculator.calculateQ1(values);
19
        q3 = BoxAndWhiskerCalculator.calculateQ3(values);
21
        assertEquals(q1, 1.5, EPSILON);
20
        assertEquals(q3, 2.5, EPSILON);
22
        values.add(new Double(4.0));
21
        values.add(new Double(4.0));
23
        q1 = BoxAndWhiskerCalculator.calculateQ1(values);
22
        q3 = BoxAndWhiskerCalculator.calculateQ3(values);
24
        assertEquals(q1, 1.5, EPSILON);
23
        assertEquals(q3, 3.5, EPSILON);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons173
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements19
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)60.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    boolean pass = false;
    1
    boolean pass = false;
    2
    try
    2
    try
    3
    BoxAndWhiskerCalculator.calculateQ1(null);
    3
    BoxAndWhiskerCalculator.calculateQ1(null);
    3
    BoxAndWhiskerCalculator.calculateQ3(null);
    Differences
    Expression1Expression2Difference
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ1(null) is a void method call, and thus it cannot be parameterized
    Expression BoxAndWhiskerCalculator.calculateQ3(null) is a void method call, and thus it cannot be parameterized
    3
    BoxAndWhiskerCalculator.calculateQ3(null);
    4
    assertTrue(pass);
    4
    assertTrue(pass);
    5
    List values = new ArrayList();
    5
    List values = new ArrayList();
    6
    double q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    6
    double q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    6
    double q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    double q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    7
    assertTrue(Double.isNaN(q1));
    7
    assertTrue(Double.isNaN(q1));
    7
    assertTrue(Double.isNaN(q3));
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    7
    assertTrue(Double.isNaN(q3));
    8
    values.add(new Double(1.0));
    8
    values.add(new Double(1.0));
    9
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    9
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    9
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    10
    assertEquals(q1, 1.0, EPSILON);
    10
    assertEquals(q1, 1.0, EPSILON);
    10
    assertEquals(q3, 1.0, EPSILON);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    10
    assertEquals(q3, 1.0, EPSILON);
    11
    values.add(new Double(2.0));
    11
    values.add(new Double(2.0));
    12
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    12
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    12
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    13
    assertEquals(q1, 1.0, EPSILON);
    13
    assertEquals(q1, 1.0, EPSILON);
    13
    assertEquals(q3, 2.0, EPSILON);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    1.02.0LITERAL_VALUE_MISMATCH
    13
    assertEquals(q3, 2.0, EPSILON);
    14
    values.add(new Double(3.0));
    14
    values.add(new Double(3.0));
    15
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    15
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    15
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    16
    assertEquals(q1, 1.5, EPSILON);
    16
    assertEquals(q1, 1.5, EPSILON);
    16
    assertEquals(q3, 2.5, EPSILON);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    1.52.5LITERAL_VALUE_MISMATCH
    16
    assertEquals(q3, 2.5, EPSILON);
    17
    values.add(new Double(4.0));
    17
    values.add(new Double(4.0));
    18
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    18
    q1 = BoxAndWhiskerCalculator.calculateQ1(values);
    18
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    calculateQ1calculateQ3METHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18
    q3 = BoxAndWhiskerCalculator.calculateQ3(values);
    19
    assertEquals(q1, 1.5, EPSILON);
    19
    assertEquals(q1, 1.5, EPSILON);
    19
    assertEquals(q3, 3.5, EPSILON);
    Differences
    Expression1Expression2Difference
    q1q3VARIABLE_NAME_MISMATCH
    1.53.5LITERAL_VALUE_MISMATCH
    19
    assertEquals(q3, 3.5, EPSILON);
    Precondition Violations (14)
    Row Violation
    1Expression BoxAndWhiskerCalculator.calculateQ1(null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    2Expression BoxAndWhiskerCalculator.calculateQ3(null) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3Expression BoxAndWhiskerCalculator.calculateQ1(null) is a void method call, and thus it cannot be parameterized
    4Expression BoxAndWhiskerCalculator.calculateQ3(null) is a void method call, and thus it cannot be parameterized
    5Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression BoxAndWhiskerCalculator.calculateQ1(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression BoxAndWhiskerCalculator.calculateQ3(values) cannot be parameterized, because it has dependencies to/from statements that will be extracted