DefaultPieDataset d = new DefaultPieDataset(); d.setValue("A", 1.0); d.setValue("B", 2.0); assertEquals("A", d.getKey(0)); assertEquals("B", d.getKey(1)); boolean pass = false; try { d.getKey(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); pass = false; try { d.getKey(2); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
KeyedObjects2D data = new KeyedObjects2D(); data.setObject("Obj1", "R1", "C1"); data.setObject("Obj2", "R2", "C2"); data.removeColumn(0); assertEquals(1, data.getColumnCount()); assertEquals("Obj2", data.getObject(1, 0)); // try negative column index boolean pass = false; try { data.removeColumn(-1); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass); // try column index too high pass = false; try { data.removeColumn(data.getColumnCount()); } catch (IndexOutOfBoundsException e) { pass = true; } assertTrue(pass);
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultPieDatasetTests.java File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java
Method name: void testGetKey() Method name: void testRemoveColumnByIndex()
Number of AST nodes: 13 Number of AST nodes: 14
1
DefaultPieDataset d = new DefaultPieDataset();
1
KeyedObjects2D data = new KeyedObjects2D();
2
        d.setValue("A", 1.0);
2
        data.setObject("Obj1", "R1", "C1");
3
        d.setValue("B", 2.
3
        data.setObject("Obj2", "R2", "C2");
4
0);
4
        data.removeColumn(0);
5
        assertEquals("A", d.getKey(0));
5
        assertEquals(1, data.getColumnCount());
6
        assertEquals("B", d.getKey(1));
6
        assertEquals("Obj2", data.getObject(1, 0));
7
        
7
        
8
        // try negative column index
8
        boolean pass = false;
9
        boolean pass = false;
9
        try {
10
        try {
10
            d.getKey(-1);
11
            data.removeColumn(-1);
11
        }
12
        }
12
        catch (IndexOutOfBoundsException e) {
13
        catch (IndexOutOfBoundsException e) {
13
            pass = true;
14
            pass = true;
14
        }
15
        }
15
        assertTrue(pass);
16
        assertTrue(pass);
16
        
17
        
18
        // try column index too high
17
        pass = false;
19
        pass = false;
18
        try {
20
        try {
19
            d.getKey(2);
21
            data.removeColumn(data.getColumnCount());
20
        }
22
        }
21
        catch (IndexOutOfBoundsException e) {
23
        catch (IndexOutOfBoundsException e) {
22
            pass = true;
24
            pass = true;
23
        }
25
        }
24
        assertTrue(pass);
26
        assertTrue(pass);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are in different classes having the same super class
Number of node comparisons73
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment7
    Number of unmapped statements in the second code fragment8
    Time elapsed for statement mapping (ms)11.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                            
    1
    KeyedObjects2D data = new KeyedObjects2D();
    Preondition Violations
    Unmatched statement KeyedObjects2D data=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    1
    KeyedObjects2D data = new KeyedObjects2D();
    1
    DefaultPieDataset d = new DefaultPieDataset();
    1
    DefaultPieDataset d = new DefaultPieDataset();
    Preondition Violations
    Unmatched statement DefaultPieDataset d=new DefaultPieDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                                                  
                                                                            
    2
    data.setObject("Obj1", "R1", "C1");
    Preondition Violations
    Unmatched statement data.setObject("Obj1","R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2
    data.setObject("Obj1", "R1", "C1");
    2
    d.setValue("A", 1.0);
    2
    d.setValue("A", 1.0);
    Preondition Violations
    Unmatched statement d.setValue("A",1.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                  
                                                                            
    3
    data.setObject("Obj2", "R2", "C2");
    Preondition Violations
    Unmatched statement data.setObject("Obj2","R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3
    data.setObject("Obj2", "R2", "C2");
    3
    d.setValue("B", 2.0);
    3
    d.setValue("B", 2.0);
    Preondition Violations
    Unmatched statement d.setValue("B",2.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                  
                                                    
    4
    data.removeColumn(0);
    Preondition Violations
    Unmatched statement data.removeColumn(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    data.removeColumn(0);
    4
    assertEquals("A", d.getKey(0));
                                                                      
                                                                                      
    5
    assertEquals(1, data.getColumnCount());
    5
    assertEquals("B", d.getKey(1));
                                                                      
                                                                                            
    6
    assertEquals("Obj2", data.getObject(1, 0));
    6
    boolean pass = false;
    7
    boolean pass = false;
    7
    try
    8
    try
    8
    d.getKey(-1);
    8
    d.getKey(-1);
    Preondition Violations
    Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                    
                                                      
    9
    data.removeColumn(-1);
    Preondition Violations
    Unmatched statement data.removeColumn(-1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement data.removeColumn(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    9
    data.removeColumn(-1);
    9
    assertTrue(pass);
    10
    assertTrue(pass);
    10
    pass = false;
    11
    pass = false;
    11
    try
    12
    try
    12
    d.getKey(2);
    12
    d.getKey(2);
    Preondition Violations
    Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                    
                                                                                              
    13
    data.removeColumn(data.getColumnCount());
    Preondition Violations
    Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    13
    data.removeColumn(data.getColumnCount());
    13
    assertTrue(pass);
    14
    assertTrue(pass);
    Precondition Violations (13)
    Row Violation
    1Unmatched statement KeyedObjects2D data=new KeyedObjects2D(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement DefaultPieDataset d=new DefaultPieDataset(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement data.setObject("Obj1","R1","C1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement d.setValue("A",1.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Unmatched statement data.setObject("Obj2","R2","C2"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    6Unmatched statement d.setValue("B",2.0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7Unmatched statement data.removeColumn(0); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    8Unmatched statement d.getKey(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    9Unmatched statement data.removeColumn(-1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement data.removeColumn(-1); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11Unmatched statement d.getKey(2); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    12Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    13Unmatched statement data.removeColumn(data.getColumnCount()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted