File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/StrokeMapTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 10 | Number of AST nodes: 10 | |||
1 | StrokeMap m1 = new StrokeMap();↵ | 1 | S↵ | |
2 | StrokeMap m↵ | 2 | impleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");↵ | |
3 | 2 = null;↵ | 3 | SimpleHistogramDataset d2 = null;↵ | |
4 | try {↵ | 4 | try {↵ | |
5 | m2 = (StrokeMap) m1.clone();↵ | 5 | d2 = (SimpleHistogramDataset) d1.clone();↵ | |
6 | }↵ | 6 | }↵ | |
7 | catch (CloneNotSupportedException e) {↵ | 7 | catch (CloneNotSupportedException e) {↵ | |
8 | e.printStackTrace();↵ | 8 | e.printStackTrace();↵ | |
9 | }↵ | 9 | }↵ | |
10 | assertTrue(m1.equals(m2));↵ | 10 | assertTrue(d1 != d2);↵ | |
11 | ↵ | 11 | ↵ | |
12 | m1.put("K1", new BasicStroke(1.1f));↵ | |||
13 | m1.put("K2", new BasicStroke(2.2f↵ | 12 | assertTrue(d1.getClass() == d2.getClass());↵ | |
14 | ));↵ | 13 | assertTrue(d1.equals(d2));↵ | |
15 | try {↵ | 14 | ↵ | |
16 | m2 = (StrokeMap) m1.clone();↵ | 15 | ↵ | |
17 | }↵ | |||
18 | catch (CloneNotSupportedException e) {↵ | |||
19 | e.printStackTrace(↵ | 16 | // check that clone is independent of the original↵ | |
17 | d2.addBin(new SimpleHistogramBin(2.0, 3.0));↵ | |||
20 | );↵ | 18 | d2.addObservation(2.3);↵ | |
21 | }↵ | |||
22 | assertTrue(m1.equals(m2)); | 19 | assertFalse(d1.equals(d2)); | |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 53 |
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 15.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); | ||||||||||||||||||||||
1 | StrokeMap m1 = new StrokeMap(); |
| | ||||||||||||||||||||||
| 2 | SimpleHistogramDataset d2 = null; | |||||||||||||||||||||||
2 | StrokeMap m2 = null; | | |||||||||||||||||||||||
3 | try | 3 | try | ||||||||||||||||||||||
|
| 4 | d2 = (SimpleHistogramDataset)d1.clone(); | ||||||||||||||||||||||
4 | m2 = (StrokeMap)m1.clone(); |
| | ||||||||||||||||||||||
| 6 | assertTrue(d1.getClass() == d2.getClass()); | |||||||||||||||||||||||
5 | assertTrue(m1.equals(m2)); |
| 7 | assertTrue(d1.equals(d2)); | |||||||||||||||||||||
6 | m1.put("K1", new BasicStroke(1.1f)); |
| | ||||||||||||||||||||||
7 | m1.put("K2", new BasicStroke(2.2f)); |
| | ||||||||||||||||||||||
10 | assertTrue(m1.equals(m2)); |
| 5 | assertTrue(d1 != d2); | |||||||||||||||||||||
|
| 8 | d2.addBin(new SimpleHistogramBin(2.0, 3.0)); | ||||||||||||||||||||||
| 9 | d2.addObservation(2.3); | |||||||||||||||||||||||
| 10 | assertFalse(d1.equals(d2)); |
Row | Violation |
---|---|
1 | Unmatched statement SimpleHistogramDataset d1=new SimpleHistogramDataset("Dataset 1"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement StrokeMap m1=new StrokeMap(); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Unmatched statement d2=(SimpleHistogramDataset)d1.clone(); 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 |
4 | Unmatched statement m2=(StrokeMap)m1.clone(); 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 |
5 | Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d2 |
6 | Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.statistics.SimpleHistogramDataset of variable d1 |
7 | Unmatched statement m1.put("K1",new BasicStroke(1.1f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement m1.put("K2",new BasicStroke(2.2f)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression d1 != d2 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Unmatched statement d2.addBin(new SimpleHistogramBin(2.0,3.0)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |