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

namespace xFunc.Test.Expressions.Maths
{

    [TestClass]
    public class SubtractionTest
    {

        private MathParser parser;

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

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

            Assert.AreEqual(-1, exp.Calculate(null));
        }

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

            Assert.AreEqual("1 - cos(x)", exp.ToString());
        }

        [TestMethod]
        public void DerivativeTest2()
        {
            Number num1 = new Number(2);
            Variable x = new Variable('x');
            Multiplication mul1 = new Multiplication(num1, x);

            Number num2 = new Number(3);
            Multiplication mul2 = new Multiplication(num2, x.Clone());

            IMathExpression exp = new Subtraction(mul1, mul2);
            IMathExpression deriv = MathParser.Differentiation(exp);

            Assert.AreEqual("-1", deriv.ToString());

            num1.Value = 5;
            num2.Value = 4;
            Assert.AreEqual("(5 * x) - (4 * x)", exp.ToString());
            Assert.AreEqual("-1", deriv.ToString());
        }

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

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

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

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

        [TestMethod]
        public void ToStringTest()
        {
            IMathExpression exp = parser.Parse("(1 - x) * 5");

            Assert.AreEqual("(1 - x) * 5", exp.ToString());
        }

    }

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

namespace xFunc.Test.Expressions.Maths
{

    [TestClass]
    public class SubtractionTest
    {

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

            Assert.AreEqual(-1, exp.Calculate(null));
        }

        [TestMethod]
        public void DerivativeTest1()
        {
            // x - sin(x)
            IMathExpression exp = new Subtraction(new Variable('x'), new Sine(new Variable('x')));
            IMathExpression deriv = exp.Differentiation();

            Assert.AreEqual("1 - (cos(x) * 1)", deriv.ToString());
        }

        [TestMethod]
        public void DerivativeTest2()
        {
            Number num1 = new Number(2);
            Variable x = new Variable('x');
            Multiplication mul1 = new Multiplication(num1, x);

            Number num2 = new Number(3);
            Multiplication mul2 = new Multiplication(num2, x.Clone());

            IMathExpression exp = new Subtraction(mul1, mul2);
            IMathExpression deriv = exp.Differentiation();

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

            num1.Value = 5;
            num2.Value = 4;
            Assert.AreEqual("(5 * x) - (4 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) - (3 * 1)", deriv.ToString());
        }

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

        [TestMethod]
        public void PartialDerivativeTest2()
        {
            IMathExpression exp = new Subtraction(new Variable('x'), new Variable('y'));
            IMathExpression deriv = exp.Differentiation();
            Assert.AreEqual("1", deriv.ToString());
        }

        [TestMethod]
        public void PartialDerivativeTest3()
        {
            IMathExpression exp = new Subtraction(new Variable('x'), new Variable('y'));
            IMathExpression deriv = exp.Differentiation(new Variable('y'));
            Assert.AreEqual("-1", deriv.ToString());
        }

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

    }

}
{'fraction_non_alphanumeric': 0.12619573215599705, 'fraction_numerical': 0.01434878587196468, 'mean_word_length': 1.993942731277533, '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': '4931986', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1477, 'n_words': 327}