161250170 6 лет назад
Родитель
Сommit
0830b594f6
1 измененных файлов с 176 добавлено и 29 удалено
  1. 176 29
      src/service/state.js

+ 176 - 29
src/service/state.js

@@ -1,46 +1,193 @@
 export const JVM_DATA_CONFIG = [
   {
-    name: '最基本的示例',
-    data: () => import('@/assets/data/viewexample_Student.json'),
+    name: 'Jmp Test',
+    data: () => import('@/assets/data/testjson/minimal_JmpTest.json'),
     raw: [{
-      filename: 'People.java',
-      code: `package viewexample;
+      filename: 'JmpTest.java',
+      code: `package minimal;
+      ;
 
-public abstract class People {
-    public int age;
-    public int id;
+      public class JmpTest {
 
-    public int solveMathProblem(int[] nums) {
-        return 0;
+        public static void testJmp(boolean a, boolean b, boolean c) {
+            //ifeq
+            if (a) {
+                TestUtil.fail();
+            } else {
+                //ifne ifeq
+                if (b || c) {
+                    //ifeq
+                    if (c) {
+                        //goto
+                        //return
+                    }else {
+                        TestUtil.fail();
+                    }
+                } else {
+                    TestUtil.fail();
+                }
+            }
+    
+        }
+    
+    
+        public static void main(String[] args) {
+            testJmp(false, false, true);
+        }
     }
-}
 `
-    }, {
-      filename: 'Student.java',
-      code: `package viewexample;
+    }
+    ]
+  },
+  {
+    name: 'Branch Test',
+    data: () => import('@/assets/data/testjson/minimal_ConditionTest.json'),
+    raw: [{
+      filename: 'ConditionTest.java',
+      code: `package minimal;
 
-public class Student extends People {
-    public Student(int id, int age) {
-        this.id = id;
-        this.age = age;
+      public class ConditionTest {
+        public static void test(int small, int big, long smallL, long bigL, float smallF, float bigF,
+                               double smallD, double bigD) {
+            if (small == 3) {
+                if (small < big && smallL < bigL && smallF < bigF && smallD < bigD) {
+    
+                } else {
+                    TestUtil.fail();
+                }
+                big++;
+                if (big > small && bigL > smallL && bigF > smallF && bigD > smallD) {
+    
+                } else {
+                    TestUtil.fail();
+                }
+            } else {
+                TestUtil.fail();
+            }
+    
+    
+            if (small <= big) {
+                if (big > small) {
+    
+                } else {
+                    TestUtil.fail();
+                }
+                if (big + 1 >= small) {
+                    if (big == small) {
+                        TestUtil.fail();
+                    }
+                    if (big != small) {
+    
+                    } else {
+                        TestUtil.fail();
+                    }
+                }
+            }
+        }
+    
+        public static void main(String[] args) {
+            test(3, 4, 5, 6, 7f, 8f, 9, 10);
+        }
+    }
+`
     }
+    ]
+  },
+  {
+    name: 'Math Test',
+    data: () => import('@/assets/data/testjson/minimal_MathTest.json'),
+    raw: [{
+      filename: 'MathTest.java',
+      code: `package minimal;
 
-    @Override
-    public int solveMathProblem(int[] nums) {
-        int sum = 0;
-        for (int num : nums) {
-            sum += num;
+      public class MathTest {
+
+        public static void test(int a, int b) {
+            if (a + b == 11 && a - b == 1 && a * b == 30 && a / b == 1) {
+                TestUtil.equalInt(a, 6);
+                TestUtil.equalInt(b, 5);
+            } else {
+                TestUtil.fail();
+            }
+    
+        }
+    
+        public static void main(String[] args) {
+            test(6, 5);
         }
-        return sum;
     }
+`
+    }
+    ]
+  }
+  ,
+  {
+    name: 'Conversion Test',
+    data: () => import('@/assets/data/testjson/minimal_ConversionTest.json'),
+    raw: [{
+      filename: 'ConditionTest.java',
+      code: `package minimal;
 
-    public static void main(String[] args) {
-        Student xiaoming = new Student(1, 18);
-        int[] nums = new int[]{1, 2};
-        int res = xiaoming.solveMathProblem(nums);//res should equals 3
+      public class ConversionTest {
+        public static void test(float flt, double db, double bigDB, float bigFLT) {
+            //d2f
+            float a = (float) db;
+            float b = flt;
+            TestUtil.equalFloat(a, b);
+            //d2i
+            int c = (int) db;
+            //f2i
+            int d = (int) flt;
+            TestUtil.equalInt(c, d);
+            TestUtil.equalInt(c, 3);
+            //d2i
+            int max = (int) bigDB;
+            TestUtil.equalInt(max, Integer.MAX_VALUE);
+            //d2L
+            long maxL = (long) bigDB;
+            if (maxL != 2147483648L) {
+                TestUtil.fail();
+            }
+            //f2i
+            if (max != (int) bigFLT) {
+                TestUtil.fail();
+            }
+            //f2l
+            if (maxL != (long) bigFLT) {
+                TestUtil.fail();
+            }
+            int toB;
+            if (TestUtil.equalInt(c, c)) {
+                toB = 128;
+            } else {
+                toB = 128;
+            }
+            //i2b
+            byte bt = (byte) toB;
+            TestUtil.equalInt(bt, -128);
+            //i2c
+            char ch = (char) toB;
+            TestUtil.equalInt(ch, 128);
+            //i2d
+            TestUtil.equalInt((int) ((double) toB + 0.0), toB);
+            //i2l & l2i
+            TestUtil.equalInt((int) ((long) toB + ch + bt), toB);
+            //l2d
+            TestUtil.equalInt((int) ((double) ((long) toB + ch + bt) + 0.0), toB);
+            //l2f
+            TestUtil.equalInt((int) ((float) ((long) toB + ch + bt) + 0.0f), toB);
+            toB <<= 8;
+            //i2s
+            short sh = (short) toB;
+            TestUtil.equalInt(sh, -toB);
+        }
+    
+        public static void main(String[] args) {
+            test(3.99f, 3.99, 2147483648.0, 2147483648.0f);
+        }
     }
-}
 `
-    }]
+    }
+    ]
   }
 ]