Ejemplo n.º 1
0
        public void TestMethodBinaryOperatorProd()
        {
            var binaryOperatorProd = new BinaryOperatorProd();

            Assert.AreEqual(6, binaryOperatorProd.getPriority());
            Assert.AreEqual("*", binaryOperatorProd.getRPolish());

            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Boolean, DataType.Boolean));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Boolean, DataType.Integer));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Boolean, DataType.Decimal));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Boolean, DataType.DecimalList));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Integer, DataType.Boolean));
            Assert.AreEqual(DataType.Integer, binaryOperatorProd.getDataType(DataType.Integer, DataType.Integer));
            Assert.AreEqual(DataType.Decimal, binaryOperatorProd.getDataType(DataType.Integer, DataType.Decimal));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Integer, DataType.DecimalList));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Decimal, DataType.Boolean));
            Assert.AreEqual(DataType.Decimal, binaryOperatorProd.getDataType(DataType.Decimal, DataType.Integer));
            Assert.AreEqual(DataType.Decimal, binaryOperatorProd.getDataType(DataType.Decimal, DataType.Decimal));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.Decimal, DataType.DecimalList));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.DecimalList, DataType.Boolean));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.DecimalList, DataType.Integer));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.DecimalList, DataType.Decimal));
            Assert.AreEqual(DataType.None, binaryOperatorProd.getDataType(DataType.DecimalList, DataType.DecimalList));

            UnitTestUtil.AssertMathTreeNodeValue(24, binaryOperatorProd.eval(new MathTreeNodeValue(3), new MathTreeNodeValue(8)));
            UnitTestUtil.AssertMathTreeNodeValue(3.0 * 8.1, binaryOperatorProd.eval(new MathTreeNodeValue(3), new MathTreeNodeValue(8.1)));
            UnitTestUtil.AssertMathTreeNodeValue(3.5 * 8.0, binaryOperatorProd.eval(new MathTreeNodeValue(3.5), new MathTreeNodeValue(8)));
            UnitTestUtil.AssertMathTreeNodeValue(3.5 * 8.1, binaryOperatorProd.eval(new MathTreeNodeValue(3.5), new MathTreeNodeValue(8.1)));
        }