File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValueTests.java | File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.java | |||
Method name: void testCloning()
|
Method name: void testCloning()
|
|||
Number of AST nodes: 9 | Number of AST nodes: 10 | |||
1 | DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5));↵ | |||
2 | DefaultKeyedValue v↵ | 1 | SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1");↵ | |
3 | 2 = null;↵ | 2 | SimpleHistogramDataset d2 = null;↵ | |
4 | try {↵ | 3 | try {↵ | |
5 | v2 = (DefaultKeyedValue) v1.clone();↵ | 4 | d2 = (SimpleHistogramDataset) d1.clone();↵ | |
6 | }↵ | 5 | }↵ | |
7 | catch (CloneNotSupportedException e) {↵ | 6 | catch (CloneNotSupportedException e) {↵ | |
8 | System.err.println("Failed to clone.");↵ | 7 | e.printStackTrace();↵ | |
9 | }↵ | 8 | }↵ | |
10 | assertTrue(v1 != v2);↵ | 9 | assertTrue(d1 != d2);↵ | |
11 | assertTrue(v1.getClass() == v2.getClass());↵ | 10 | assertTrue(d1.getClass() == d2.getClass());↵ | |
12 | assertTrue(v1.equals(v2));↵ | 11 | assertTrue(d1.equals(d2));↵ | |
13 | ↵ | 12 | ↵ | |
14 | // confirm that the clone is independent of the original↵ | 13 | // check that clone is independent of the original↵ | |
15 | v2.setValue(new Double(12.3)↵ | 14 | d2.addBin(new SimpleHistogramBin(2.0, 3.0));↵ | |
16 | );↵ | 15 | d2.addObservation(2.3);↵ | |
17 | assertFalse(v1.equals(v2)); | 16 | assertFalse(d1.equals(d2)); | |
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.3 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 40 |
Number of mapped statements | 8 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 28.9 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); |
| 1 | SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); | ||||||||||||||||||||||||||
2 | DefaultKeyedValue v2 = null; |
| 2 | SimpleHistogramDataset d2 = null; | ||||||||||||||||||||||||||
3 | try |
| 3 | try | ||||||||||||||||||||||||||
4 | v2 = (DefaultKeyedValue)v1.clone(); |
| 4 | d2 = (SimpleHistogramDataset)d1.clone(); | ||||||||||||||||||||||||||
5 | assertTrue(v1 != v2); |
| 5 | assertTrue(d1 != d2); | ||||||||||||||||||||||||||
6 | assertTrue(v1.getClass() == v2.getClass()); |
| 6 | assertTrue(d1.getClass() == d2.getClass()); | ||||||||||||||||||||||||||
7 | assertTrue(v1.equals(v2)); |
| 7 | assertTrue(d1.equals(d2)); | ||||||||||||||||||||||||||
|
| 8 | d2.addBin(new SimpleHistogramBin(2.0, 3.0)); | |||||||||||||||||||||||||||
8 | v2.setValue(new Double(12.3)); |
| | |||||||||||||||||||||||||||
|
| 9 | d2.addObservation(2.3); | |||||||||||||||||||||||||||
9 | assertFalse(v1.equals(v2)); |
| 10 | assertFalse(d1.equals(d2)); |
Row | Violation |
---|---|
1 | Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression new SimpleHistogramDataset("Dataset 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression new DefaultKeyedValue("Test",new Double(45.5)) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression new SimpleHistogramDataset("Dataset 1") cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized |
7 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
8 | Expression e cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression System.err.println("Failed to clone.") is a void method call, and thus it cannot be parameterized |
11 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized |
12 | Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression (SimpleHistogramDataset)d1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression v2 cannot be unified with expression d2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
15 | Expression v2 cannot be unified with expression d2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
16 | Expression v1 cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
17 | Unmatched statement d2.addBin(new SimpleHistogramBin(2.0,3.0)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
18 | Unmatched statement v2.setValue(new Double(12.3)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
19 | Unmatched statement d2.addObservation(2.3); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
20 | Expression v2 cannot be unified with expression d2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
21 | Expression v2 cannot be unified with expression d2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
22 | Expression v1 cannot be unified with expression d1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
23 | Clone fragment #1 returns variable v2 with type org.jfree.data.DefaultKeyedValue , while Clone fragment #2 returns variable d2 with type org.jfree.data.statistics.SimpleHistogramDataset |