File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/DialValueIndicatorTests.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 | DialValueIndicator i1 = new DialValueIndicator(0);↵ | |||
2 | DialValueIndicator i↵ | 1 | XYSeries s1 = new XYSeries("Series");↵ | |
2 | s1.add(1.0, 1.1);↵ | |||
3 | XYSeriesCollection c1 = new XYSeriesCollection();↵ | |||
4 | c1.addSeries(s1);↵ | |||
3 | 2 = null;↵ | 5 | XYSeriesCollection c2 = null;↵ | |
4 | try {↵ | 6 | try {↵ | |
5 | i2 = (DialValueIndicator) i1.clone();↵ | 7 | c2 = (XYSeriesCollection) c1.clone();↵ | |
6 | }↵ | 8 | }↵ | |
7 | catch (CloneNotSupportedException e) {↵ | 9 | catch (CloneNotSupportedException e) {↵ | |
8 | e.printStackTrace();↵ | 10 | e.printStackTrace();↵ | |
9 | }↵ | 11 | }↵ | |
10 | assertTrue(i1 != i2);↵ | 12 | assertTrue(c1 != c2);↵ | |
11 | assertTrue(i1.getClass() == i2.getClass());↵ | 13 | assertTrue(c1.getClass() == c2.getClass());↵ | |
12 | assertTrue(i1.equals(i2));↵ | 14 | assertTrue(c1.equals(c2));↵ | |
13 | ↵ | |||
14 | // check that the listener lists are independent↵ | 15 | // check ↵ | |
15 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵ | 16 | independence↵ | |
16 | i1.addChangeListener(l1);↵ | 17 | s1.↵ | |
17 | assertTrue(i1.hasListener(l1));↵ | 18 | setDescription("XYZ");↵ | |
18 | assertFalse(i2.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) | 52.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 1 | XYSeries s1 = new XYSeries("Series"); | |||||||||||||||||||||||||||
|
| 2 | s1.add(1.0, 1.1); | |||||||||||||||||||||||||||
1 | DialValueIndicator i1 = new DialValueIndicator(0); |
| 3 | XYSeriesCollection c1 = new XYSeriesCollection(); | ||||||||||||||||||||||||||
|
| 4 | c1.addSeries(s1); | |||||||||||||||||||||||||||
2 | DialValueIndicator i2 = null; |
| 5 | XYSeriesCollection c2 = null; | ||||||||||||||||||||||||||
3 | try | 6 | try | |||||||||||||||||||||||||||
4 | i2 = (DialValueIndicator)i1.clone(); |
| 7 | c2 = (XYSeriesCollection)c1.clone(); | ||||||||||||||||||||||||||
5 | assertTrue(i1 != i2); |
| 8 | assertTrue(c1 != c2); | ||||||||||||||||||||||||||
6 | assertTrue(i1.getClass() == i2.getClass()); |
| 9 | assertTrue(c1.getClass() == c2.getClass()); | ||||||||||||||||||||||||||
7 | assertTrue(i1.equals(i2)); |
| 10 | assertTrue(c1.equals(c2)); | ||||||||||||||||||||||||||
8 | MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); | | ||||||||||||||||||||||||||||
9 | i1.addChangeListener(l1); |
| | |||||||||||||||||||||||||||
10 | assertTrue(i1.hasListener(l1)); |
| | |||||||||||||||||||||||||||
|
| 11 | s1.setDescription("XYZ"); | |||||||||||||||||||||||||||
11 | assertFalse(i2.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 DialValueIndicator(0) 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 DialValueIndicator(0) 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 (DialValueIndicator)i1.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 i2 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 i2 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 i1 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 i1.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(i1.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(i2.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 i1, i2 , while Clone fragment #2 returns variables c1, c2 |