-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #999 from jqno/rewrites-instantiation
Rewrites instantiation
- Loading branch information
Showing
144 changed files
with
4,458 additions
and
4,409 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
73 changes: 73 additions & 0 deletions
73
...l/jqno/equalsverifier/integration/extended_contract/PrefabValuesForFieldInRecordTest.java
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,73 @@ | ||
package nl.jqno.equalsverifier.integration.extended_contract; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import nl.jqno.equalsverifier.internal.testhelpers.ExpectedException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class PrefabValuesForFieldInRecordTest { | ||
|
||
@Test | ||
public void fail_whenRecordHasSinglePrecondition() { | ||
ExpectedException | ||
.when(() -> EqualsVerifier.forClass(SinglePrecondition.class).verify()) | ||
.assertFailure() | ||
.assertMessageContains("Record:", "failed to run constructor", "[1]"); | ||
} | ||
|
||
@Test | ||
public void succeed_whenRecordHasSinglePrecondition_givenPrefabValuesForField() { | ||
EqualsVerifier | ||
.forClass(SinglePrecondition.class) | ||
.withPrefabValuesForField("i", 111, 142) | ||
.verify(); | ||
} | ||
|
||
@Test | ||
public void fail_whenRecordHasDualPrecondition() { | ||
ExpectedException | ||
.when(() -> EqualsVerifier.forClass(DualPrecondition.class).verify()) | ||
.assertFailure() | ||
.assertMessageContains("Record:", "failed to run constructor", "[1, 1]"); | ||
} | ||
|
||
@Test | ||
public void fail_whenRecordHasDualPrecondition_givenPrefabValuesForOnlyOneField() { | ||
ExpectedException | ||
.when(() -> | ||
EqualsVerifier | ||
.forClass(DualPrecondition.class) | ||
.withPrefabValuesForField("x", 111, 142) | ||
.verify() | ||
) | ||
.assertFailure() | ||
.assertMessageContains("Record:", "failed to run constructor", "[111, 1]"); | ||
} | ||
|
||
@Test | ||
public void succeed_whenRecordHasDualPrecondition_givenPrefabValueForBothFields() { | ||
EqualsVerifier | ||
.forClass(DualPrecondition.class) | ||
.withPrefabValuesForField("x", 111, 142) | ||
.withPrefabValuesForField("y", 505, 555) | ||
.verify(); | ||
} | ||
|
||
record SinglePrecondition(int i) { | ||
public SinglePrecondition { | ||
if (i < 100 || i > 200) { | ||
throw new IllegalArgumentException("i must be between 100 and 200! But was " + i); | ||
} | ||
} | ||
} | ||
|
||
record DualPrecondition(int x, int y) { | ||
public DualPrecondition { | ||
if (x < 100 || x > 200) { | ||
throw new IllegalArgumentException("x must be between 100 and 200! But was " + x); | ||
} | ||
if (y < 500 || y > 600) { | ||
throw new IllegalArgumentException("y must be between 500 and 600! But was " + y); | ||
} | ||
} | ||
} | ||
} |
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
28 changes: 0 additions & 28 deletions
28
...-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassAccessorRecordTest.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
...ier-16/src/test/java/nl/jqno/equalsverifier/internal/reflection/ClassProbeRecordTest.java
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,16 @@ | ||
package nl.jqno.equalsverifier.internal.reflection; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ClassProbeRecordTest { | ||
|
||
@Test | ||
public void isRecord() { | ||
var probe = new ClassProbe<>(SimpleRecord.class); | ||
assertTrue(probe.isRecord()); | ||
} | ||
|
||
record SimpleRecord(int i) {} | ||
} |
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
71 changes: 0 additions & 71 deletions
71
...test/java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessorCopyingTest.java
This file was deleted.
Oops, something went wrong.
126 changes: 0 additions & 126 deletions
126
...java/nl/jqno/equalsverifier/internal/reflection/RecordObjectAccessorModificationTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.