<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using xFunc.Maths;
using xFunc.Maths.Expressions;

namespace xFunc.Test.Expressions.Maths
{

    [TestClass]
    public class MultiplicationTest
    {

        private MathParser parser;

        [TestInitialize]
        public void TestInit()
        {
            parser = new MathParser();
        }

        [TestMethod]
        public void CalculateTest()
        {
            IMathExpression exp = parser.Parse("2 * 2");

            Assert.AreEqual(2 * 2, exp.Calculate(null));
        }

        [TestMethod]
        public void DerivativeTest1()
        {
            IMathExpression exp = MathParser.Differentiation(parser.Parse("sin(2x)"));

            Assert.AreEqual("cos(2 * x) * 2", exp.ToString());
        }

        [TestMethod]
        public void DerivativeTest2()
        {
            // 2x
            Number num = new Number(2);
            Variable x = new Variable('x');

            IMathExpression exp = new Multiplication(num, x);
            IMathExpression deriv = MathParser.Differentiation(exp);

            Assert.AreEqual("2", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("3 * x", exp.ToString());
            Assert.AreEqual("2", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest1()
        {
            IMathExpression exp = parser.Parse("deriv((x + 1) * (y + x), x)").Differentiation();
            Assert.AreEqual("(y + x) + (x + 1)", exp.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest2()
        {
            IMathExpression exp = parser.Parse("deriv((y + 1) * (3 + x), y)").Differentiation();
            Assert.AreEqual("3 + x", exp.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest3()
        {
            IMathExpression exp = parser.Parse("deriv((x + 1) * (y + x), y)").Differentiation();
            Assert.AreEqual("x + 1", exp.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest4()
        {
            IMathExpression exp = parser.Parse("deriv((x + 1) * (3 + x), y)").Differentiation();
            Assert.AreEqual("0", exp.ToString());
        }

        [TestMethod]
        public void ToStringTest()
        {
            IMathExpression exp = parser.Parse("2sin(x)");

            Assert.AreEqual("2 * sin(x)", exp.ToString());
        }

    }

}<commit_msg>Edited Mul tests<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using xFunc.Maths;
using xFunc.Maths.Expressions;

namespace xFunc.Test.Expressions.Maths
{

    [TestClass]
    public class MultiplicationTest
    {

        [TestMethod]
        public void CalculateTest()
        {
            IMathExpression exp = new Multiplication(new Number(2), new Number(2));

            Assert.AreEqual(4, exp.Calculate(null));
        }

        [TestMethod]
        public void DerivativeTest1()
        {
            IMathExpression exp = new Multiplication(new Number(2), new Variable('x'));
            IMathExpression deriv = exp.Differentiation();

            Assert.AreEqual("2 * 1", deriv.ToString());
        }

        [TestMethod]
        public void DerivativeTest2()
        {
            // 2x
            Number num = new Number(2);
            Variable x = new Variable('x');

            IMathExpression exp = new Multiplication(num, x);
            IMathExpression deriv = exp.Differentiation();

            Assert.AreEqual("2 * 1", deriv.ToString());

            num.Value = 3;
            Assert.AreEqual("3 * x", exp.ToString());
            Assert.AreEqual("2 * 1", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest1()
        {
            // (x + 1) * (y + x)
            IMathExpression exp = new Multiplication(new Addition(new Variable('x'), new Number(1)), new Addition(new Variable('y'), new Variable('x')));
            IMathExpression deriv = exp.Differentiation();
            Assert.AreEqual("(1 * (y + x)) + ((x + 1) * 1)", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest2()
        {
            // (y + 1) * (3 + x)
            IMathExpression exp = new Multiplication(new Addition(new Variable('y'), new Number(1)), new Addition(new Number(3), new Variable('x')));
            IMathExpression deriv = exp.Differentiation(new Variable('y'));
            Assert.AreEqual("1 * (3 + x)", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest3()
        {
            // (x + 1) * (y + x)
            IMathExpression exp = new Multiplication(new Addition(new Variable('x'), new Number(1)), new Addition(new Variable('y'), new Variable('x')));
            IMathExpression deriv = exp.Differentiation(new Variable('y'));
            Assert.AreEqual("(x + 1) * 1", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest4()
        {
            // (x + 1) * (3 + x)
            IMathExpression exp = new Multiplication(new Addition(new Variable('x'), new Number(1)), new Addition(new Number(3), new Variable('x')));
            IMathExpression deriv = exp.Differentiation(new Variable('y'));
            Assert.AreEqual("0", deriv.ToString());
        }

    }

}
{'fraction_non_alphanumeric': 0.1347227391142538, 'fraction_numerical': 0.013211760327502792, 'mean_word_length': 2.0128923766816142, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7552476', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1461, 'n_words': 337}