Test nested record matching, thankfully switch does the heavy lifting, fixes #349
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 42s
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 42s
This commit is contained in:
parent
ff715a22cf
commit
443b8b0c09
20
resources/bytecode/javFiles/OverloadNestedPattern.jav
Normal file
20
resources/bytecode/javFiles/OverloadNestedPattern.jav
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import java.lang.Object;
|
||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Float;
|
||||||
|
|
||||||
|
public record R(Object nested) {}
|
||||||
|
|
||||||
|
public class OverloadNestedPattern {
|
||||||
|
|
||||||
|
public Integer m(R(R(Integer a)), R(Integer b)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer m(R(R(Float a)), R(Float b)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer m(R(Integer a), R(Integer b)) {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
@ -838,7 +838,6 @@ public class TestComplete {
|
|||||||
var instance = clazz.getDeclaredConstructor().newInstance();
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Not implemented")
|
|
||||||
@Test
|
@Test
|
||||||
public void testOverloadPattern() throws Exception {
|
public void testOverloadPattern() throws Exception {
|
||||||
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav");
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav");
|
||||||
@ -864,6 +863,27 @@ public class TestComplete {
|
|||||||
assertEquals(m3.invoke(instance, 10), 10);
|
assertEquals(m3.invoke(instance, 10), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverloadNestedPattern() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadNestedPattern.jav");
|
||||||
|
var clazz = classFiles.get("OverloadNestedPattern");
|
||||||
|
var rec = classFiles.get("R");
|
||||||
|
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
var ctor = rec.getDeclaredConstructor(Object.class);
|
||||||
|
var r1 = ctor.newInstance(1);
|
||||||
|
var r2 = ctor.newInstance(r1);
|
||||||
|
|
||||||
|
var m = clazz.getDeclaredMethod("m", rec, rec);
|
||||||
|
assertEquals(m.invoke(instance, r2, r1), 1);
|
||||||
|
|
||||||
|
var r3 = ctor.newInstance(2f);
|
||||||
|
var r4 = ctor.newInstance(r3);
|
||||||
|
assertEquals(m.invoke(instance, r4, r3), 2);
|
||||||
|
|
||||||
|
assertEquals(m.invoke(instance, r1, r1), 3);
|
||||||
|
}
|
||||||
|
|
||||||
//@Ignore("Not implemented")
|
//@Ignore("Not implemented")
|
||||||
@Test
|
@Test
|
||||||
public void testOverloadPatternMatching() throws Exception {
|
public void testOverloadPatternMatching() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user