Skip to content

Commit 72a4ec6

Browse files
CopilotGarciat
andcommitted
Inline remaining variables in ParsedTypeTest (listType, mapType, nestedType, types, fieldType)
Co-authored-by: Garciat <118277+Garciat@users.noreply.github.com>
1 parent 43a45e3 commit 72a4ec6

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

src/test/java/com/garciat/typeclasses/impl/ParsedTypeTest.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,21 @@ void parseObjectArrayType() {
3939

4040
@Test
4141
void parseParameterizedType() throws Exception {
42-
Type listType = new Ty<List<String>>() {}.type();
43-
44-
assertThat(ParsedType.parse(listType))
42+
assertThat(ParsedType.parse(new Ty<List<String>>() {}.type()))
4543
.isEqualTo(new App(new Const(List.class), new Const(String.class)));
4644
}
4745

4846
@Test
4947
void parseMultipleTypeParameters() throws Exception {
50-
Type mapType = new Ty<Map<String, Integer>>() {}.type();
51-
52-
assertThat(ParsedType.parse(mapType))
48+
assertThat(ParsedType.parse(new Ty<Map<String, Integer>>() {}.type()))
5349
.isEqualTo(
5450
new App(
5551
new App(new Const(Map.class), new Const(String.class)), new Const(Integer.class)));
5652
}
5753

5854
@Test
5955
void parseNestedParameterizedType() throws Exception {
60-
Type nestedType = new Ty<List<Optional<String>>>() {}.type();
61-
62-
assertThat(ParsedType.parse(nestedType))
56+
assertThat(ParsedType.parse(new Ty<List<Optional<String>>>() {}.type()))
6357
.isEqualTo(
6458
new App(
6559
new Const(List.class),
@@ -68,9 +62,7 @@ void parseNestedParameterizedType() throws Exception {
6862

6963
@Test
7064
void parseAll() throws Exception {
71-
Type[] types = {String.class, Integer.class, int.class};
72-
73-
assertThat(ParsedType.parseAll(types))
65+
assertThat(ParsedType.parseAll(new Type[] {String.class, Integer.class, int.class}))
7466
.isEqualTo(
7567
List.of(new Const(String.class), new Const(Integer.class), new Primitive(int.class)));
7668
}
@@ -88,20 +80,20 @@ void parseTypeVariableInParameterizedType() throws Exception {
8880
class TestClass<T> {
8981
List<T> field;
9082
}
91-
Type fieldType = TestClass.class.getDeclaredField("field").getGenericType();
9283
TypeVariable<?> tv = TestClass.class.getTypeParameters()[0];
9384

94-
assertThat(ParsedType.parse(fieldType)).isEqualTo(new App(new Const(List.class), new Var(tv)));
85+
assertThat(ParsedType.parse(TestClass.class.getDeclaredField("field").getGenericType()))
86+
.isEqualTo(new App(new Const(List.class), new Var(tv)));
9587
}
9688

9789
@Test
9890
void parseWildcardTypeThrows() throws Exception {
9991
class TestClass {
10092
List<?> field;
10193
}
102-
Type fieldType = TestClass.class.getDeclaredField("field").getGenericType();
10394

104-
assertThatThrownBy(() -> ParsedType.parse(fieldType))
95+
assertThatThrownBy(
96+
() -> ParsedType.parse(TestClass.class.getDeclaredField("field").getGenericType()))
10597
.isInstanceOf(IllegalArgumentException.class)
10698
.hasMessageContaining("wildcard");
10799
}

0 commit comments

Comments
 (0)