File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/StrokeMapTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValueTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 10 | Number of AST nodes: 9 | |||
1 | StrokeMap m1 = new StrokeMap();↵ | |||
2 | StrokeMap m↵ | 1 | DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));↵ | |
3 | 2 = null;↵ | 2 | DefaultKeyedValue v2 = null;↵ | |
4 | try {↵ | 3 | try {↵ | |
5 | m2 = (StrokeMap) m1.clone();↵ | 4 | v2 = (DefaultKeyedValue) v1.clone();↵ | |
6 | }↵ | 5 | }↵ | |
7 | catch (CloneNotSupportedException e) {↵ | 6 | catch (CloneNotSupportedException e) {↵ | |
8 | e.printStackTrace();↵ | 7 | ↵ | |
9 | }↵ | |||
10 | assertTrue(m1.equals(m2));↵ | |||
11 | ↵ | |||
12 | m1.put("K1", new BasicStroke(1.1f));↵ | |||
13 | m1.put("K2", new BasicStroke(2.2f↵ | 8 | System.err.println("Failed to clone.");↵ | |
9 | }↵ | |||
10 | assertTrue(v1 != v2);↵ | |||
11 | assertTrue(v1.getClass() == v2.getClass());↵ | |||
14 | ));↵ | 12 | assertTrue(v1.equals(v2));↵ | |
15 | try {↵ | 13 | ↵ | |
16 | m2 = (StrokeMap) m1.clone();↵ | 14 | ↵ | |
17 | }↵ | |||
18 | catch (CloneNotSupportedException e) {↵ | |||
19 | e.printStackTrace(↵ | 15 | // confirm that the clone is independent of the original↵ | |
20 | );↵ | 16 | v2.setValue(new Double(12.3));↵ | |
21 | }↵ | |||
22 | assertTrue(m1.equals(m2)); | 17 | assertFalse(v1.equals(v2)); | |
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.4 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 47 |
Number of mapped statements | 3 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 6 |
Time elapsed for statement mapping (ms) | 13.3 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); | ||||||||||||||||||||||||
1 | StrokeMap m1 = new StrokeMap(); |
| | ||||||||||||||||||||||||
| 2 | DefaultKeyedValue v2 = null; | |||||||||||||||||||||||||
2 | StrokeMap m2 = null; | | |||||||||||||||||||||||||
3 | try |
| 3 | try | |||||||||||||||||||||||
|
| 4 | v2 = (DefaultKeyedValue)v1.clone(); | ||||||||||||||||||||||||
4 | m2 = (StrokeMap)m1.clone(); |
| | ||||||||||||||||||||||||
| 6 | assertTrue(v1.getClass() == v2.getClass()); | |||||||||||||||||||||||||
5 | assertTrue(m1.equals(m2)); |
| 7 | assertTrue(v1.equals(v2)); | |||||||||||||||||||||||
6 | m1.put("K1", new BasicStroke(1.1f)); |
| | ||||||||||||||||||||||||
7 | m1.put("K2", new BasicStroke(2.2f)); |
| | ||||||||||||||||||||||||
10 | assertTrue(m1.equals(m2)); |
| 5 | assertTrue(v1 != v2); | |||||||||||||||||||||||
|
| 8 | v2.setValue(new Double(12.3)); | ||||||||||||||||||||||||
| 9 | assertFalse(v1.equals(v2)); |
Row | Violation |
---|---|
1 | Unmatched statement DefaultKeyedValue v1=new DefaultKeyedValue("Test",new Double(45.5)); 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 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
5 | Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized |
6 | Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
9 | Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized |
10 | Unmatched statement v2=(DefaultKeyedValue)v1.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 |
11 | 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 |
12 | Type org.jfree.chart.StrokeMap of variable m2 does not match with type org.jfree.data.DefaultKeyedValue of variable v2 |
13 | Type org.jfree.chart.StrokeMap of variable m1 does not match with type org.jfree.data.DefaultKeyedValue of variable v1 |
14 | 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 |
15 | 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 |
16 | Expression m1.equals(m2) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression v1 != v2 cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |