File path: /jfreechart-1.0.10/tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.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 | MultipleXYSeriesLabelGenerator g1↵ | |||
2 | = new MultipleXYSeriesLabelGenerator();↵ | |||
3 | MultipleXYSeriesLabelGenerator g↵ | 1 | XYSeries s1 = new XYSeries("Series");↵ | |
2 | s1.add(1.0, 1.1);↵ | |||
3 | XYSeriesCollection c1 = new XYSeriesCollection();↵ | |||
4 | c1.addSeries(s1);↵ | |||
4 | 2 = null;↵ | 5 | XYSeriesCollection c2 = null;↵ | |
5 | try {↵ | 6 | try {↵ | |
6 | g2 = (MultipleXYSeriesLabelGenerator) g1.clone();↵ | 7 | c2 = (XYSeriesCollection) c1.clone();↵ | |
7 | }↵ | 8 | }↵ | |
8 | catch (CloneNotSupportedException e) {↵ | 9 | catch (CloneNotSupportedException e) {↵ | |
9 | e.printStackTrace();↵ | 10 | e.printStackTrace();↵ | |
10 | }↵ | 11 | }↵ | |
11 | assertTrue(g1 != g2);↵ | 12 | assertTrue(c1 != c2);↵ | |
12 | assertTrue(g1.getClass() == g2.getClass());↵ | 13 | assertTrue(c1.getClass() == c2.getClass());↵ | |
13 | assertTrue(g1.equals(g2));↵ | 14 | assertTrue(c1.equals(c2));↵ | |
14 | // check independence↵ | 15 | // check independence↵ | |
15 | g1.addSeriesLabel(3, "Add3");↵ | 16 | s1.↵ | |
16 | assertFalse(g1.equals(g2));↵ | |||
17 | g2.addSeriesLabel(3, "Add3");↵ | 17 | setDescription("XYZ");↵ | |
18 | assertTrue(g1.equals(g2)); | 18 | 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 | 76 |
Number of mapped statements | 9 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 3 |
Time elapsed for statement mapping (ms) | 58.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | XYSeries s1 = new XYSeries("Series"); | |||||||||||||||||||||||||||||
|
| 2 | s1.add(1.0, 1.1); | |||||||||||||||||||||||||||||
1 | MultipleXYSeriesLabelGenerator g1 = new MultipleXYSeriesLabelGenerator(); |
| 3 | XYSeriesCollection c1 = new XYSeriesCollection(); | ||||||||||||||||||||||||||||
2 | MultipleXYSeriesLabelGenerator g2 = null; |
| 5 | XYSeriesCollection c2 = null; | ||||||||||||||||||||||||||||
3 | try | 6 | try | |||||||||||||||||||||||||||||
4 | g2 = (MultipleXYSeriesLabelGenerator)g1.clone(); |
| 7 | c2 = (XYSeriesCollection)c1.clone(); | ||||||||||||||||||||||||||||
5 | assertTrue(g1 != g2); |
| 8 | assertTrue(c1 != c2); | ||||||||||||||||||||||||||||
6 | assertTrue(g1.getClass() == g2.getClass()); |
| 9 | assertTrue(c1.getClass() == c2.getClass()); | ||||||||||||||||||||||||||||
7 | assertTrue(g1.equals(g2)); |
| 10 | assertTrue(c1.equals(c2)); | ||||||||||||||||||||||||||||
8 | g1.addSeriesLabel(3, "Add3"); |
| 4 | c1.addSeries(s1); | ||||||||||||||||||||||||||||
9 | assertFalse(g1.equals(g2)); |
| 12 | assertFalse(c1.equals(c2)); | ||||||||||||||||||||||||||||
10 | g2.addSeriesLabel(3, "Add3"); |
| | |||||||||||||||||||||||||||||
|
| 11 | s1.setDescription("XYZ"); | |||||||||||||||||||||||||||||
11 | assertTrue(g1.equals(g2)); |
| |
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 MultipleXYSeriesLabelGenerator() 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 (MultipleXYSeriesLabelGenerator)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression (XYSeriesCollection)c1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression g2 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) |
8 | Expression g2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
9 | Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
10 | Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized |
13 | Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized |
14 | Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public void addSeriesLabel(int, java.lang.String) , public void addSeries(org.jfree.data.xy.XYSeries) |
15 | Expression g1.addSeriesLabel(3,"Add3") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression c1.addSeries(s1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression g1.addSeriesLabel(3,"Add3") is a void method call, and thus it cannot be parameterized |
18 | Expression c1.addSeries(s1) is a void method call, and thus it cannot be parameterized |
19 | Expression g2 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) |
20 | Expression g2 cannot be unified with expression c2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
21 | Expression g1 cannot be unified with expression c1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
22 | Unmatched statement g2.addSeriesLabel(3,"Add3"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
23 | Unmatched statement s1.setDescription("XYZ"); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted |
24 | Unmatched statement assertTrue(g1.equals(g2)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
25 | Clone fragment #1 returns variables g2, g1 , while Clone fragment #2 returns variables |