refactor + test: removed comments and fixed Test-Assertion
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 4m56s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 4m56s
This commit is contained in:
parent
8f094eb025
commit
114de0b236
@ -7,9 +7,6 @@ sealed interface List permits LinkedElem, Elem {}
|
||||
public record LinkedElem<T>(T a,List l) implements List{}
|
||||
public record Elem<T>(T c) implements List{}
|
||||
|
||||
|
||||
//Wie gehe ich mit Type Erasure durch den Compiler um? Elemente werden wegen Generics immer zu Object umgewandelt, default Case muss also auch vom Type Object sein.
|
||||
//Dadurch entsteht folgendes Constraint: java.lang.Integer <. T, das nicht aufgelöst werden kann.
|
||||
public class GenericRecordSwitchCase {
|
||||
public main(o) {
|
||||
return switch(o) {
|
||||
|
@ -795,10 +795,10 @@ public class TestComplete {
|
||||
|
||||
|
||||
var listWithMoreThanOneElement = constructorLinkedElem.newInstance(5, constructorLinkedElem.newInstance(1, constructorElem.newInstance(5)));
|
||||
assertEquals(swtch.invoke(instance, listWithMoreThanOneElement), 2);
|
||||
assertEquals(swtch.invoke(instance, listWithMoreThanOneElement), 5);
|
||||
|
||||
var listWithOneElement = constructorLinkedElem.newInstance(5, constructorElem.newInstance(5));
|
||||
assertEquals(swtch.invoke(instance, listWithOneElement), 1);
|
||||
assertEquals(swtch.invoke(instance, listWithOneElement), 5);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user