
// verify that unknown integrals don't simplify
Verify(Integrate(x,a,b)Exp(Sin(x)),Integrate(x,a,b)Exp(Sin(x)));
Verify(Integrate(x    )Exp(Sin(x)),Integrate(x    )Exp(Sin(x)));

// Verify that Yacas cannot integrate these expressions.
// Yacas needs to return the integration unevaluated, or
// return a correct answer (if it happens to be able to do
// these integrals in the future).
TestNonIntegrable(_expr) <-- Verify(Type(expr) = "Integrate",True);

// The following two used to get the interpreter into an infinite
// loop. Fixed in version 1.0.51
// FIXED!!! TestNonIntegrable(Integrate(x)(x*Ln(x)));
TestNonIntegrable(Integrate(x)Sin(Exp(x)));
Verify(Integrate(x) x^(-1),Ln(x)); // Well done Jonathan! ;-)
Verify(Integrate(x) 1/x,Ln(x) );

Verify(Integrate(x) 1/x^2, -x^ -1 );
Verify(Integrate(x) 6/x^2, (-6)*x^-1);
Verify(Integrate(x) 3/Sin(x),3*Ln(1/Sin(x)-Cos(x)/Sin(x)) );

Verify(Integrate(x) Ln(x), x*Ln(x)-x );
Verify(Integrate(x) x^5000, x^5001/5001 );
Verify(Integrate(x) 1/Tan(x), Ln(Sin(x)) );
Verify(Integrate(x) 1/Cosh(x)^2, Tanh(x) );
Verify(Integrate(x) 1/Sqrt(3-x^2), ArcSin(x/Sqrt(3)) );
Verify(Integrate(x) Erf(x), x*Erf(x)+1/(Exp(x^2)*Sqrt(Pi)) );
Verify(Integrate(x) Sin(x)/(2*y+4),(-Cos(x))/(2*y+4));
Verify(Integrate(x, {logAbs -> True})1/x, Ln(Abs(x)));
Verify(Integrate(x,a,b, {logAbs -> True})1/x, Ln(Abs(b))-Ln(Abs(a)));


TestNonIntegrable(Integrate(x) x^(1/x));
TestNonIntegrable(Integrate(x) x^(Sin(x)));
TestNonIntegrable(Integrate(x) Exp(x^2));
TestNonIntegrable(Integrate(x) Sin(x^2));

TestMathPiper(Integrate(x,0,A)Sin(x),1 - Cos(A));
TestMathPiper(Integrate(x,0,A)x^2,(A^3)/3);
TestMathPiper(Integrate(x,0,A)Sin(B*x),1/B-Cos(A*B)/B);
TestMathPiper(Integrate(x,0,A)(x^2+2*x+1)/(x+1),(A^2)/2+A);
TestMathPiper(Integrate(x,0,A)(x+1)/(x^2+2*x+1),Ln(A+1));

// Check that threaded integration works
Verify((Integrate(x,0,1) {1,x*x,1+x})-{1,1/3,3/2},{0,0,0});


// Test MatchLinear: code heavily used with integration
LocalSymbols(TestMatchLinearTrue,TestMatchLinearFalse) [

  TestMatchLinearTrue(_var,_expr,_expected) <--
  [
    Local(a,b);
    Verify(MatchLinear(var,expr),True);
    a:=Simplify(Matched'a()-expected[1]);
    b:=Simplify(Matched'b()-expected[2]);
    `TestMathPiper(@a,0);
    `TestMathPiper(@b,0);
  ];
  TestMatchLinearFalse(_var,_expr) <--
  [
    Local(a,b);
    Verify(MatchLinear(var,expr),False);
  ];

  TestMatchLinearTrue(x,(R+1)*x+(T-1),{(R+1),(T-1)});
  TestMatchLinearTrue(x,x+T,{1,T});
  TestMatchLinearTrue(x,a*x+b,{a,b});
  TestMatchLinearFalse(x,Sin(x)*x+(T-1));
  TestMatchLinearFalse(x,x+Sin(x));

];

