diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-17 16:42:32 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-03-17 16:42:32 +0700 |
commit | 58830078585fd045c92737ce56cb693b903f5545 (patch) | |
tree | a43bc08e564e940516a165c260957f11f4aa357f | |
parent | 5bb8f42d3b2b65bf8ba12e9aaf6c892b5134fa36 (diff) | |
download | aspectj-58830078585fd045c92737ce56cb693b903f5545.tar.gz aspectj-58830078585fd045c92737ce56cb693b903f5545.zip |
Add 'yield' usage to Java 12/13 switch expressions tests
So far this was a slight oversight, no test using 'yield' existed in the
'features193' test suite. Better late than never.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
-rw-r--r-- | tests/features193/Switch1.java | 15 | ||||
-rw-r--r-- | tests/features193/Switch2.java | 15 | ||||
-rw-r--r-- | tests/features193/Switch3.java | 17 |
3 files changed, 28 insertions, 19 deletions
diff --git a/tests/features193/Switch1.java b/tests/features193/Switch1.java index 1daeeff6f..625fe15a0 100644 --- a/tests/features193/Switch1.java +++ b/tests/features193/Switch1.java @@ -7,11 +7,14 @@ public class Switch1 { } public static int one(Color color) { - int result = switch(color) { - case R -> 0; - case G -> 1; - case B -> 2; - default -> 3; + int result = switch (color) { + case R -> 0; + case G -> { + int number4 = 8 / 2; + yield number4 /4; + } + case B -> 2; + default -> 3; }; return result; } @@ -19,4 +22,4 @@ public class Switch1 { enum Color { R, G, B, Y; -}
\ No newline at end of file +} diff --git a/tests/features193/Switch2.java b/tests/features193/Switch2.java index c4acc82d9..391ea30f9 100644 --- a/tests/features193/Switch2.java +++ b/tests/features193/Switch2.java @@ -7,11 +7,14 @@ public class Switch2 { } public static int one(Color color) { - int result = switch(color) { - case R -> 0; - case G -> 1; - case B -> 2; - default -> 3; + int result = switch (color) { + case R -> 0; + case G -> { + int number4 = 8 / 2; + yield number4 /4; + } + case B -> 2; + default -> 3; }; return result; } @@ -25,4 +28,4 @@ aspect X { int around(): call(* one(..)) { return proceed()*2; } -}
\ No newline at end of file +} diff --git a/tests/features193/Switch3.java b/tests/features193/Switch3.java index a99622d75..90e528125 100644 --- a/tests/features193/Switch3.java +++ b/tests/features193/Switch3.java @@ -7,15 +7,18 @@ public class Switch3 { } public static int one(Color color) { - int result = switch(color) { - case R -> foo(0); - case G -> foo(1); - case B -> foo(2); - default -> foo(3); + int result = switch (color) { + case R -> foo(0); + case G -> { + int number4 = foo(1) - 2; + yield number4 +2; + } + case B -> foo(2); + default -> foo(3); }; return result; } - + public static final int foo(int i) { return i+1; } @@ -29,4 +32,4 @@ aspect X { int around(): call(* foo(..)) { return proceed()*3; } -}
\ No newline at end of file +} |