-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Tests to test record feature of jpf * modify the setBootstrapMethod(...) to check the type of bootstrap method more precisely to handle each type with the correct scheme
- Loading branch information
Showing
2 changed files
with
71 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package java17; | ||
|
||
import gov.nasa.jpf.util.test.TestJPF; | ||
import org.junit.Test; | ||
|
||
public class RecordFeatureTest extends TestJPF { | ||
record Point(int x, int y){} | ||
// Official documents suggest that fields of "record" are "private" and "final". | ||
// So we are testing by direct access. It should fail here at compile time, but do not know why it works. | ||
@Test | ||
public void testRecordFieldsDirectly(){ | ||
if (verifyNoPropertyViolation()){ | ||
Point point = new Point(4, 5); | ||
assertEquals("",4,point.x); | ||
assertEquals("",5,point.y); | ||
} | ||
} | ||
@Test | ||
public void testRecordFields(){ | ||
if (verifyNoPropertyViolation()){ | ||
Point point = new Point(4, 5); | ||
assertEquals("",4,point.x()); | ||
assertEquals("",5,point.y()); | ||
} | ||
} | ||
@Test | ||
public void testRecordEquality(){ | ||
if (verifyNoPropertyViolation()){ | ||
Point point1 = new Point(4,5); | ||
Point point2 = new Point(4,5); | ||
Point point3 = new Point(3,5); | ||
assertEquals("",point1, point2); | ||
assertNotEquals("",point1, point3); | ||
} | ||
} | ||
@Test | ||
public void testRecordHashCode() { | ||
if (verifyNoPropertyViolation()){ | ||
Point point1 = new Point(4, 5); | ||
Point point2 = new Point(4, 5); | ||
Point point3 = new Point(3,5); | ||
assertEquals("", point1.hashCode(), point2.hashCode()); | ||
assertNotEquals("",point1.hashCode(),point3.hashCode()); | ||
} | ||
} | ||
@Test | ||
public void testRecordToString() { | ||
if (verifyNoPropertyViolation()){ | ||
Point point = new Point(4, 5); | ||
assertEquals("Point[x=4, y=5]", point.toString()); | ||
} | ||
} | ||
} |