Example #1
0
        public void TestLogicalNot()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(0, 0, -1, true, false, false),
                new IntegerTestResult(-1, 0, 0, false, true, false),
                new IntegerTestResult(1, 0, -2, true, false, false),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.NOT);
        }
Example #2
0
        public void TestLogicalAnd()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(0, 0, 0, false, true, false),
                new IntegerTestResult(0, 1, 0, false, true, false),
                new IntegerTestResult(1, 0, 0, false, true, false),
                new IntegerTestResult(1, 1, 1, false, false, false),
                new IntegerTestResult(1, -1, 1, false, false, false),
                new IntegerTestResult(-1, 1, 1, false, false, false),
                new IntegerTestResult(-1, -1, -1, true, false, false),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.AND_REG_LIT);
        }
Example #3
0
        public void TestModulo()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(2, 2, 0, false, true, false),
                new IntegerTestResult(1, 2, 1, false, false, false),
                new IntegerTestResult(2, 1, 0, false, true, false),
                new IntegerTestResult(0, 2, 0, false, true, false),
                new IntegerTestResult(-1, 1, 0, false, true, false),
                new IntegerTestResult(1, -1, 0, false, true, false),
                new IntegerTestResult(-1, -1, 0, false, true, false),
                new IntegerTestResult(-4, -3, -1, true, false, false),
                new IntegerTestResult(-3, -4, -3, true, false, false),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.MOD_LIT_REG);
        }
Example #4
0
        public void TestSubtraction()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(1, 2, 1, false, false, false),
                new IntegerTestResult(-1, -2, -1, true, false, false), // -2--1 == -2+1 == -1
                new IntegerTestResult(-1, 2, 3, false, false, false),  // 2--1 == 2+1 == 3
                new IntegerTestResult(1, -2, -3, true, false, false),  // -2-1 == -3
                new IntegerTestResult(0, 0, 0, false, true, false),
                new IntegerTestResult(0, 1, 1, false, false, false),
                new IntegerTestResult(1, 0, -1, true, false, false),

                // These will overflow.
                new IntegerTestResult(-1, int.MaxValue, -2147483648, true, false, true),
                new IntegerTestResult(1, int.MinValue, 2147483647, false, false, true),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.SUB_REG_LIT);
        }
Example #5
0
        public void TestMultiplication()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(1, 2, 2, false, false, false),
                new IntegerTestResult(-1, -2, 2, false, false, false), // -1 * -2 == 3
                new IntegerTestResult(-1, 2, -2, true, false, false),  // -1 * 2 == -2
                new IntegerTestResult(1, -2, -2, true, false, false),  // 1 * -2 == -2
                new IntegerTestResult(0, 0, 0, false, true, false),
                new IntegerTestResult(0, 1, 0, false, true, false),
                new IntegerTestResult(1, 0, 0, false, true, false),

                // These will overflow.
                new IntegerTestResult(int.MaxValue, 2, -2, true, false, true),
                new IntegerTestResult(-1073741825, 2, 2147483646, false, false, true),
                new IntegerTestResult(int.MinValue, 2, 0, false, true, true),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.MUL_REG_REG);
        }
Example #6
0
        public void TestAddition()
        {
            var table = new []
            {
                #region TESTS
                new IntegerTestResult(1, 2, 3, false, false, false),
                new IntegerTestResult(-1, -2, -3, true, false, false), // -1+-2 == -1-2 == -3
                new IntegerTestResult(-1, 2, 1, false, false, false),
                new IntegerTestResult(1, -2, -1, true, false, false),  // 1+-2 == 1 - 2 == -1
                new IntegerTestResult(0, 0, 0, false, true, false),
                new IntegerTestResult(0, 1, 1, false, false, false),
                new IntegerTestResult(1, 0, 1, false, false, false),
                new IntegerTestResult(1, -1, 0, false, true, false),

                // These will overflow.
                new IntegerTestResult(int.MaxValue, 1, -2147483648, true, false, true),
                new IntegerTestResult(int.MinValue, -1, 2147483647, false, false, true),
                #endregion
            };

            IntegerTestResult.RunTests(Vm, table, OpCode.ADD_LIT_REG);
        }