]> source.dussan.org Git - aspectj.git/commitdiff
Add 'yield' usage to Java 12/13 switch expressions tests
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 17 Mar 2021 09:42:32 +0000 (16:42 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Wed, 17 Mar 2021 09:42:32 +0000 (16:42 +0700)
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>
tests/features193/Switch1.java
tests/features193/Switch2.java
tests/features193/Switch3.java

index 1daeeff6fadf053cd70c4bf912a50fb401ad9b72..625fe15a0be0d5c3ec7d0fd3c37f649bdc832abd 100644 (file)
@@ -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
+}
index c4acc82d94b485ffaa7168d033e4c7ad2a5f48e7..391ea30f90c5ebebb149adc9d19fa914c5f57975 100644 (file)
@@ -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
+}
index a99622d75de4aaddb241913e4c1e663a07eff102..90e5281259241d5d7901cf7a07d1d2e218edd29a 100644 (file)
@@ -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
+}