File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialTextAnnotationTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 11 | Number of AST nodes: 12 | |||
1 | DialTextAnnota↵ | 1 | XYSeries s1 = new XYSeries("Series");↵ | |
2 | s1.add(1.0, 1.1);↵ | |||
2 | tion a1 = new DialTextAnnotation("A1");↵ | 3 | XYSeriesCollection c1 = new ↵ | |
3 | DialTextAnnota↵ | 4 | XYSeriesCollection();↵ | |
5 | c1.addSeries(s1);↵ | |||
4 | tion a2 = null;↵ | 6 | XYSeriesCollection c2 = null;↵ | |
5 | try {↵ | 7 | try {↵ | |
6 | a2 = (DialTextAnnotation) a1.clone();↵ | 8 | c2 = (XYSeriesCollection) c1.clone();↵ | |
7 | }↵ | 9 | }↵ | |
8 | catch (CloneNotSupportedException e) {↵ | 10 | catch (CloneNotSupportedException e) {↵ | |
9 | e.printStackTrace();↵ | 11 | e.printStackTrace();↵ | |
10 | }↵ | 12 | }↵ | |
11 | assertTrue(a1 != a2);↵ | 13 | assertTrue(c1 != c2);↵ | |
12 | assertTrue(a1.getClass() == a2.getClass());↵ | 14 | assertTrue(c1.getClass() == c2.getClass());↵ | |
13 | assertTrue(a1.equals(a2));↵ | 15 | assertTrue(c1.equals(c2));↵ | |
14 | ↵ | |||
15 | // check that the listener lists are independent↵ | 16 | // check ↵ | |
16 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵ | |||
17 | a1.addChangeListener(l1);↵ | |||
18 | assertTrue(a1.hasListener(l1)↵ | 17 | independence↵ | |
19 | );↵ | 18 | s1.setDescription("XYZ");↵ | |
20 | assertFalse(a2.hasListener(l1)); | 19 | assertFalse(c1.equals(c2)); | |
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.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 83 |
Number of mapped statements | 7 |
Number of unmapped statements in the first code fragment | 4 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 50.5 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | XYSeries s1 = new XYSeries("Series"); | |||||||||||||||||||||||||||
|
| 2 | s1.add(1.0, 1.1); | |||||||||||||||||||||||||||
1 | DialTextAnnotation a1 = new DialTextAnnotation("A1"); |
| 3 | XYSeriesCollection c1 = new XYSeriesCollection(); | ||||||||||||||||||||||||||
|
| 4 | c1.addSeries(s1); | |||||||||||||||||||||||||||
2 | DialTextAnnotation a2 = null; |
| 5 | XYSeriesCollection c2 = null; | ||||||||||||||||||||||||||
3 | try | 6 | try | |||||||||||||||||||||||||||
4 | a2 = (DialTextAnnotation)a1.clone(); |
| 7 | c2 = (XYSeriesCollection)c1.clone(); | ||||||||||||||||||||||||||
5 | assertTrue(a1 != a2); |
| 8 | assertTrue(c1 != c2); | ||||||||||||||||||||||||||
6 | assertTrue(a1.getClass() == a2.getClass()); |
| 9 | assertTrue(c1.getClass() == c2.getClass()); | ||||||||||||||||||||||||||
7 | assertTrue(a1.equals(a2)); |
| 10 | assertTrue(c1.equals(c2)); | ||||||||||||||||||||||||||
8 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); | | ||||||||||||||||||||||||||||
9 | a1.addChangeListener(l1); |
| | |||||||||||||||||||||||||||
10 | assertTrue(a1.hasListener(l1)); |
| | |||||||||||||||||||||||||||
|
| 11 | s1.setDescription("XYZ"); | |||||||||||||||||||||||||||
11 | assertFalse(a2.hasListener(l1)); |
| | |||||||||||||||||||||||||||
|
| 12 | assertFalse(c1.equals(c2)); |
Row | Violation |
---|---|
1 | Unmatched statement XYSeries s1=new XYSeries("Series"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
2 | Unmatched statement s1.add(1.0,1.1); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
3 | Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression new DialTextAnnotation("A1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression new XYSeriesCollection() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Unmatched statement c1.addSeries(s1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
8 | Expression (DialTextAnnotation)a1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression a2 cannot be unified with expression c2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
11 | Expression a2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
12 | Expression a1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
13 | Unmatched statement a1.addChangeListener(l1); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement assertTrue(a1.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
16 | Unmatched statement assertFalse(a2.hasListener(l1)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
17 | Unmatched statement assertFalse(c1.equals(c2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Clone fragment #1 returns variables a1, a2 , while Clone fragment #2 returns variables c1, c2 |