File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java | File path: /jfreechart-1.0.10/tests/org/jfree/chart/title/junit/LegendGraphicTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 11 | Number of AST nodes: 10 | |||
1 | XYAreaRenderer2 r1 = new XYAreaRenderer2();↵ | |||
2 | Rectangle rect = new Rectangle(1, 2, 3, 4);↵ | 1 | Rectangle r = new Rectangle(1, 2, 3, 4);↵ | |
3 | r1.setLegendArea(rect);↵ | 2 | LegendGraphic g1 = new LegendGraphic(r, Color.black);↵ | |
4 | XYAreaRenderer2 r2 = null;↵ | 3 | LegendGraphic g2 = null;↵ | |
5 | try {↵ | 4 | try {↵ | |
6 | r2 = (XYAreaRenderer2) r1.clone();↵ | 5 | g2 = (LegendGraphic) g1.clone();↵ | |
7 | }↵ | 6 | }↵ | |
8 | catch (CloneNotSupportedException e) {↵ | 7 | catch (CloneNotSupportedException e) {↵ | |
9 | e.printStackTrace();↵ | 8 | e.printStackTrace();↵ | |
10 | }↵ | 9 | }↵ | |
11 | assertTrue(r1 != r2);↵ | 10 | assertTrue(g1 != g2);↵ | |
12 | assertTrue(r1.getClass() == r2.getClass());↵ | 11 | assertTrue(g1.getClass() == g2.getClass());↵ | |
13 | assertTrue(r1.equals(r2));↵ | 12 | assertTrue(g1.equals(g2));↵ | |
13 | ↵ | |||
14 | // check independence↵ | 14 | // check independence↵ | |
15 | rect.setBounds(99, 99, 99, 99);↵ | 15 | r.setBounds(4, 3, 2, 1);↵ | |
16 | assertFalse(r1.equals(r2)); | 16 | assertFalse(g1.equals(g2)); | |
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 | 44 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 40.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | XYAreaRenderer2 r1 = new XYAreaRenderer2(); |
| 2 | LegendGraphic g1 = new LegendGraphic(r, Color.black); | ||||||||||||||||||||||||||
2 | Rectangle rect = new Rectangle(1, 2, 3, 4); |
| 1 | Rectangle r = new Rectangle(1, 2, 3, 4); | ||||||||||||||||||||||||||
3 | r1.setLegendArea(rect); |
| | |||||||||||||||||||||||||||
4 | XYAreaRenderer2 r2 = null; |
| 3 | LegendGraphic g2 = null; | ||||||||||||||||||||||||||
5 | try | 4 | try | |||||||||||||||||||||||||||
6 | r2 = (XYAreaRenderer2)r1.clone(); |
| 5 | g2 = (LegendGraphic)g1.clone(); | ||||||||||||||||||||||||||
7 | assertTrue(r1 != r2); |
| 6 | assertTrue(g1 != g2); | ||||||||||||||||||||||||||
8 | assertTrue(r1.getClass() == r2.getClass()); |
| 7 | assertTrue(g1.getClass() == g2.getClass()); | ||||||||||||||||||||||||||
9 | assertTrue(r1.equals(r2)); |
| 8 | assertTrue(g1.equals(g2)); | ||||||||||||||||||||||||||
10 | rect.setBounds(99, 99, 99, 99); |
| 9 | r.setBounds(4, 3, 2, 1); | ||||||||||||||||||||||||||
11 | assertFalse(r1.equals(r2)); |
| 10 | assertFalse(g1.equals(g2)); |
Row | Violation |
---|---|
1 | Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression new XYAreaRenderer2() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression new LegendGraphic(r,Color.black) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement r1.setLegendArea(rect); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Expression (XYAreaRenderer2)r1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression (LegendGraphic)g1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
9 | Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
10 | Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
11 | Expression r2 cannot be unified with expression g2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
12 | Expression r2 cannot be unified with expression g2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
13 | Expression r1 cannot be unified with expression g1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
14 | Clone fragment #1 returns variables r1, rect , while Clone fragment #2 returns variables |