Ejemplo n.º 1
0
        public void TestInt()
        {
            int[]    testArray    = new int[] { 1, 2, 3, 4, 5 };
            Delegate ShowDelegate = EHandler.CreateMethod <int>((il) =>
            {
                EVar result  = EVar.CreateVar <int>();
                EArray Model = testArray;
                ELoop.For(Model, (loadCurrentElement) =>
                {
                    result.Store(result + loadCurrentElement);
                });
                result.Load();
            }).Compile();

            Assert.Equal(15, ((Func <int>)ShowDelegate)());
        }
Ejemplo n.º 2
0
        public void DoubleOperator()
        {
            Delegate test = EHandler.CreateMethod <double>((il) =>
            {
                EVar temp_var1 = (double)15;
                EVar temp_var2 = EVar.CreateVarFromObject((double)10);
                EVar temp_var3 = 3.5;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / (double)5);
                temp_var2.Store(temp_var2 - temp_var3);
                temp_var2.Store(temp_var2 * 3.0);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <double> action = (Func <double>)test;

            Assert.Equal(4.5, action());
        }
Ejemplo n.º 3
0
        public void FloatOperator()
        {
            Delegate test = EHandler.CreateMethod <float>((il) =>
            {
                EVar temp_var1 = (float)15;
                EVar temp_var2 = EVar.CreateVarFromObject((float)10);
                EVar temp_var3 = (float)3.5;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / (float)5);
                temp_var2.Store(temp_var2 - temp_var3);
                temp_var2.Store(temp_var2 * 3.0);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <float> action = (Func <float>)test;

            Assert.Equal((float)4.5, action());
        }
Ejemplo n.º 4
0
        public void ULongOperator()
        {
            Delegate test = EHandler.CreateMethod <ulong>((il) =>
            {
                EVar temp_var1 = (ulong)15;
                EVar temp_var2 = EVar.CreateVarFromObject((ulong)10);
                EVar temp_var3 = (ulong)0;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / (ulong)5);
                temp_var2.Store(temp_var2 * 3689348814741910323);
                temp_var2.Store(temp_var2 + temp_var3);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <ulong> action = (Func <ulong>)test;

            Assert.Equal(ulong.MaxValue, action());
        }
Ejemplo n.º 5
0
        public void LongOperator()
        {
            Delegate test = EHandler.CreateMethod <long>((il) =>
            {
                EVar temp_var1 = (long)15;
                EVar temp_var2 = EVar.CreateVarFromObject((long)10);
                EVar temp_var3 = (long)2;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / (long)5);
                temp_var2.Store(temp_var2 * 1844674407370955161);
                temp_var2.Store(temp_var2 + temp_var3);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <long> action = (Func <long>)test;

            Assert.Equal(long.MaxValue, action());
        }
Ejemplo n.º 6
0
        public void UIntOperator()
        {
            Delegate test = EHandler.CreateMethod <uint>((il) =>
            {
                EVar temp_var1 = (uint)15;
                EVar temp_var2 = EVar.CreateVarFromObject((uint)10);
                EVar temp_var3 = (uint)0;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / 5);
                temp_var2.Store(temp_var2 * 858993459);
                temp_var2.Store(temp_var2 + temp_var3);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <uint> action = (Func <uint>)test;

            Assert.Equal(uint.MaxValue, action());
        }
Ejemplo n.º 7
0
        public void ShortOperator()
        {
            Delegate test = EHandler.CreateMethod <short>((il) =>
            {
                EVar temp_var1 = (short)15;
                EVar temp_var2 = EVar.CreateVarFromObject((short)10);
                EVar temp_var3 = (short)2;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / 5);
                temp_var2.Store(temp_var2 * 6553);
                temp_var2.Store(temp_var2 + temp_var3);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <short> action = (Func <short>)test;

            Assert.Equal(short.MaxValue, action());
        }
Ejemplo n.º 8
0
        public void ByteOperator()
        {
            Delegate test = EHandler.CreateMethod <byte>((il) =>
            {
                EVar temp_var1 = (byte)15;
                EVar temp_var2 = EVar.CreateVarFromObject((byte)10);
                EVar temp_var3 = (byte)5;
                temp_var2.Store(temp_var1 + temp_var2);
                temp_var2.Store(temp_var2 / 5);
                temp_var2.Store(temp_var2 * 50);
                temp_var2.Store(temp_var2 + temp_var3);
                temp_var2--;
                temp_var2++;
                temp_var2.Load();
            }).Compile();
            Func <byte> action = (Func <byte>)test;

            Assert.Equal(byte.MaxValue, action());
        }
Ejemplo n.º 9
0
        public static void TestDefault()
        {
            Action action = (Action)(EHandler.CreateMethod <ENull>((il) =>
            {
                EMethod methodInfoHelper = typeof(Console);
                EVar stringHandler = "16";
                EVar intHandler = 10;
                EVar doubleHandler = 0.00;
                EJudge.If(EDefault.IsDefault(doubleHandler.TypeHandler, () => { doubleHandler.Load(); }))(() =>
                {
                    EMethod.Load(typeof(Console)).ExecuteMethod <string>("WriteLine", "doubleHandler是默认值");
                }).Else(() =>
                {
                    doubleHandler.This();
                    methodInfoHelper.ExecuteMethod <double>("WriteLine");
                });
            }).Compile());

            action();
        }
Ejemplo n.º 10
0
        public void ShowInt()
        {
            //测试int上限 无临时变量
            Delegate test = EHandler.CreateMethod <int>((il) => {
                EVar temp_var = int.MaxValue;
                EMethod.Load(typeof(Console)).ExecuteMethod <int>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <int> action = (Func <int>)test;

            Assert.Equal(int.MaxValue, action());

            //测试int下限 有临时变量
            Delegate test2 = EHandler.CreateMethod <int>((il) => {
                EVar temp_var = EVar.CreateVarFromObject(int.MinValue);
                EMethod.Load(typeof(Console)).ExecuteMethod <int>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <int> action2 = (Func <int>)test2;

            Assert.Equal(int.MinValue, action2());
        }
Ejemplo n.º 11
0
        public void ShowBoolean()
        {
            //测试float上限 无临时变量
            Delegate test = EHandler.CreateMethod <bool>((il) =>
            {
                EVar temp_var = true;
                EMethod.Load(typeof(Console)).ExecuteMethod <bool>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <bool> action = (Func <bool>)test;

            Assert.Equal(true, action());

            //测试float下限 有临时变量
            Delegate test2 = EHandler.CreateMethod <bool>((il) =>
            {
                EVar temp_var = EVar.CreateVarFromObject(false);
                EMethod.Load(typeof(Console)).ExecuteMethod <bool>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <bool> action2 = (Func <bool>)test2;

            Assert.Equal(false, action2());
        }
Ejemplo n.º 12
0
        public void ShowChar()
        {
            //测试char 无临时变量
            Delegate test = EHandler.CreateMethod <char>((il) =>
            {
                EVar temp_var = 'a';
                EMethod.Load(typeof(Console)).ExecuteMethod <char>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <char> action = (Func <char>)test;

            Assert.Equal('a', action());

            //测试string 有临时变量
            Delegate test2 = EHandler.CreateMethod <char>((il) =>
            {
                EVar temp_var = EVar.CreateVarFromObject('`');
                EMethod.Load(typeof(Console)).ExecuteMethod <char>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <char> action2 = (Func <char>)test2;

            Assert.Equal('`', action2());
        }
Ejemplo n.º 13
0
        public void ShowString()
        {
            //测试string 无临时变量
            Delegate test = EHandler.CreateMethod <string>((il) =>
            {
                EVar temp_var = string.Empty;
                EMethod.Load(typeof(Console)).ExecuteMethod <string>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <string> action = (Func <string>)test;

            Assert.Equal(string.Empty, action());

            //测试string 有临时变量
            Delegate test2 = EHandler.CreateMethod <string>((il) =>
            {
                EVar temp_var = EVar.CreateVarFromObject(string.Empty);
                EMethod.Load(typeof(Console)).ExecuteMethod <string>("WriteLine", temp_var);
                temp_var.Load();
            }).Compile();
            Func <string> action2 = (Func <string>)test2;

            Assert.Equal(string.Empty, action2());
        }