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/SimpleHistogramBinTests.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 | SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true);↵ | |
2 | b1.setItemCount(99);↵ | |||
3 | 2 = null;↵ | 3 | SimpleHistogramBin b2 = null;↵ | |
4 | try {↵ | 4 | try {↵ | |
5 | v2 = (DefaultKeyedValue) v1.clone();↵ | 5 | b2 = (SimpleHistogramBin) b1.clone();↵ | |
6 | }↵ | 6 | }↵ | |
7 | catch (CloneNotSupportedException e) {↵ | 7 | catch (CloneNotSupportedException e) {↵ | |
8 | System.err.println("Failed to clone.");↵ | 8 | System.err.println("Failed to clone.");↵ | |
9 | }↵ | 9 | }↵ | |
10 | assertTrue(v1 != v2);↵ | 10 | assertTrue(b1 != b2);↵ | |
11 | assertTrue(v1.getClass() == v2.getClass());↵ | 11 | assertTrue(b1.getClass() == b2.getClass());↵ | |
12 | assertTrue(v1.equals(v2));↵ | 12 | assertTrue(b1.equals(b2));↵ | |
13 | ↵ | 13 | ↵ | |
14 | // confirm that the clone is independent of the original↵ | 14 | // check that clone is independent of the original↵ | |
15 | v2.setValue(new Double(12.3));↵ | 15 | b2.setItemCount(111);↵ | |
16 | assertFalse(v1.equals(v2)); | 16 | assertFalse(b1.equals(b2)); | |
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.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 41 |
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) | 15.8 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); |
| 1 | SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true); | ||||||||||||||||||||||||||
|
| 2 | b1.setItemCount(99); | |||||||||||||||||||||||||||
2 | DefaultKeyedValue v2 = null; |
| 3 | SimpleHistogramBin b2 = null; | ||||||||||||||||||||||||||
3 | try | 4 | try | |||||||||||||||||||||||||||
4 | v2 = (DefaultKeyedValue)v1.clone(); |
| 5 | b2 = (SimpleHistogramBin)b1.clone(); | ||||||||||||||||||||||||||
5 | assertTrue(v1 != v2); |
| 6 | assertTrue(b1 != b2); | ||||||||||||||||||||||||||
6 | assertTrue(v1.getClass() == v2.getClass()); |
| 7 | assertTrue(b1.getClass() == b2.getClass()); | ||||||||||||||||||||||||||
7 | assertTrue(v1.equals(v2)); |
| 8 | assertTrue(b1.equals(b2)); | ||||||||||||||||||||||||||
8 | v2.setValue(new Double(12.3)); |
| | |||||||||||||||||||||||||||
|
| 9 | b2.setItemCount(111); | |||||||||||||||||||||||||||
9 | assertFalse(v1.equals(v2)); |
| 10 | assertFalse(b1.equals(b2)); |
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 SimpleHistogramBin(1.1,2.2,false,true) 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 SimpleHistogramBin(1.1,2.2,false,true) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement b1.setItemCount(99); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Expression (DefaultKeyedValue)v1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression (SimpleHistogramBin)b1.clone() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass() |
9 | Expression v2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public final native Class<? extends org.jfree.data.DefaultKeyedValue> getClass() , public final native Class<? extends org.jfree.data.statistics.SimpleHistogramBin> getClass() |
10 | Expression v2 cannot be unified with expression b2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
11 | Expression v2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
12 | Expression v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
13 | 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 |
14 | Unmatched statement b2.setItemCount(111); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Expression v2 cannot be unified with expression b2 , because common superclass type org.jfree.util.PublicCloneable cannot be passed as an argument to public boolean equals(java.lang.Object) |
16 | Expression v2 cannot be unified with expression b2 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
17 | Expression v1 cannot be unified with expression b1 , because common superclass org.jfree.util.PublicCloneable does not declare member(s) public boolean equals(java.lang.Object) |
18 | Clone fragment #1 returns variable v2 with type org.jfree.data.DefaultKeyedValue , while Clone fragment #2 returns variable b2 with type org.jfree.data.statistics.SimpleHistogramBin |