<commit_before>package unitTest;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import model.*;

public class PolynomialTest {
	Expression term;
	Variable x;

	@Before
	public void setUp() throws Exception {
		x = new Variable("x",-2);
		ArrayList<Expression> exp = new ArrayList<Expression>();
		exp.add(new Power(x, new Constant(7.0),2.0));
		exp.add(new Power(x, new Constant(4.0),-5.0));
		exp.add(new Power(x, new Constant(3.0),3.0));
		exp.add(new Power(x, new Constant(2.0),10.0));
		exp.add(new Power(x, new Constant(1.0),-9.0));
		exp.add(new Constant(2));
		term = new Add(exp);
				
	}

	@Test
	public void testCalc() throws Exception {
		assertEquals(term.calc() , -300, 0.0000001);
	}
	
	@Test
	public void testderiv() throws Exception {
		assertEquals(term.derivative(x).calc(), 1043.0, 0.0000001);
	}
}<commit_msg>[Test] Added test for Polynomial in case of partial derivative<commit_after>package unitTest;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import model.*;

public class PolynomialTest {
	Expression term;
	Expression pTerm;
	Variable x;
	Variable y;
	Variable z;

	@Before
	public void setUp() throws Exception {
		x = new Variable("x",-2);
		y = new Variable("y",1);
		z = new Variable("z",3);

		ArrayList<Expression> exp = new ArrayList<>();
		exp.add(new Power(x, new Constant(7.0),2.0));
		exp.add(new Power(x, new Constant(4.0),-5.0));
		exp.add(new Power(x, new Constant(3.0), 3.0));
		exp.add(new Power(x, new Constant(2.0),10.0));
		exp.add(new Power(x, new Constant(1.0),-9.0));
		exp.add(new Constant(2));
		term = new Add(exp);

		ArrayList<Expression> pExp = new ArrayList<>();
		pExp.add(new Power(x, new Constant(3.0)));
		pExp.add(new Power(y, new Constant(3.0)));
		pExp.add(new Power(z, new Constant(3.0)));
		pExp.add(new Multiply(new Power(x, new Constant(1.0)), new Multiply(new Power(y, new Constant(1.0)), new Power(z, new Constant(1.0))),-3.0));
		pTerm = new Add(pExp);

	}

	@Test
	public void testCalc() throws Exception {
		assertEquals(term.calc() , -300, 0.0000001);
		assertEquals(pTerm.calc(), 38, 0.0000001);
	}
	
	@Test
	public void testderiv() throws Exception {
		assertEquals(term.derivative(x).calc(), 1043.0, 0.0000001);
		assertEquals(pTerm.derivative(x).calc(), 3, 0.0000001);
	}
}
{'fraction_non_alphanumeric': 0.17393126571668063, 'fraction_numerical': 0.054065381391450125, 'mean_word_length': 4.376126126126126, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4368674', 'n_tokens_mistral': 982, 'n_tokens_neox': 868, 'n_words': 213}