forked from JavaTX/JavaCompilerCore
Test Case für geschachtelte Pattern erstellt
This commit is contained in:
parent
b1b7c23166
commit
0311f5ed77
18
src/test/java/parser/NestedPattern.jav
Normal file
18
src/test/java/parser/NestedPattern.jav
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
record Point(int x, int y) {}
|
||||||
|
enum Color { RED, GREEN, BLUE }
|
||||||
|
interface Shape {}
|
||||||
|
record ColoredPoint(Point pt, Color color) {}
|
||||||
|
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) implements Shape {}
|
||||||
|
|
||||||
|
class PatternMatching {
|
||||||
|
void printColorOfUpperLeftPoint(Shape shape)
|
||||||
|
{
|
||||||
|
switch (shape) {
|
||||||
|
case Rectangle(ColoredPoint(Point pt, Color color), ColoredPoint lowerRight) -> System.out.println("x: " + pt.x() + " / color: " + color + " / lowerRight: " + lowerRight);
|
||||||
|
|
||||||
|
default -> System.out.println("not a rectangle");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user