
    
def test01():
   __cdbkernel__=create_scope()    
   ex:=3x + x**2 + a x**2 + b x;
   q=SympyBridge(ex)
   q.from_sympy( str(sympy.collect(q.to_sympy(), $x$)) )
   tst:= x**2 (a + 1) + x ( b + 3) - @(ex);
   assert(tst==0)
   print("Test 01 passed")
    
test01()

def test02():
   __cdbkernel__=create_scope()
   {r,t}::Coordinate;
   f::Depends(r,t);
   ex:=f*A;
   \partial{#}::PartialDerivative;
   ex:= \partial_{r}{ f + (\sin(r)**2)**2 };
   map_sympy(ex)
   tst:= \partial_{r}{f} + 4 \sin(r)**3 \cos(r) - @(ex);
   assert(tst==0)
   print("Test 02 passed")

test02()

def test03():
   __cdbkernel__=create_scope() 
   \tau::Coordinate;
   \partial{#}::Derivative(\tau);
   r::Depends(\tau);
   ex:=\partial{r};
   q=SympyBridge(ex)
   q.from_sympy(str(q.to_sympy()))
   tst:= \partial{r} - @(ex);
   assert(tst==0)
   print("Test 03a passed")

   ex:=\partial{\partial{r}};
   q=SympyBridge(ex)
   q.from_sympy(str(q.to_sympy()))
   tst:= \partial{\partial{r}} - @(ex);
   assert(tst==0)
   print("Test 03b passed")

test03()


def test04():
   __cdbkernel__=create_scope() 
   ex:= 1 - (-1)**2;
   simplify(_)
   assert(ex==0)
   print("Test 04 passed")

test04()

from cdb.sympy.calculus import integrate
      
def test05():
   __cdbkernel__=create_scope() 
   ex:= \exp(-x);
   tst = integrate(ex, ($x$, 0, $\infty$))
   assert(tst==1)
   print("Test 05 passed")

test05()
      
