

def test01():
    __cdbkernel__=create_scope()
    {i,j,k}::Indices;
    {i,j,k}::Integer(1..3);
    rl:= N_{i j} -> A_{i j};
    ex:= N_{1 2};
    substitute(ex, rl)
    tst:= A_{1 2} - @(ex);
    assert(tst==0)
    print("Test 01 passed")

test01()



# A{#}::NumericalFlat.
# ex:= A{3}{B}{D};
# 
# \bar{#}::DiracBar;
# ex:= \bar{4 \psi};
# 

def test02():
    __cdbkernel__=create_scope()
    i::ImaginaryI;
    ex:= i i A_{m n} i  B^{m} i i C i D i ;
    tst:= - A_{m n} B^{m} C D i - @(ex);
    assert(tst==0)
    print("Test 02 passed")

test02()

def test03():
    __cdbkernel__=create_scope()
    ex:= (2 r**2)**6;
    tst:= 64 r**(12) - @(ex);
    assert(tst==0)
    print("Test 03a passed")
    a::Integer;    
    ex:= (2 r**2)**a;
    tst:= 2**a r**(2 a) - @(ex);
    assert(tst==0)
    print("Test 03b passed")
    ex:= (2 r**2)**b;
    tst:= (2 r**2)**b - @(ex);
    assert(tst==0)
    print("Test 03c passed")
    ex:= (2 r)**6;
    tst:= 64 r**6 - @(ex);
    assert(tst==0)
    print("Test 03d passed")
    ex:= (2 (3 r)**2)**6;
    tst:= 34012224 r**(12) - @(ex);
    assert(tst==0)
    print("Test 03e passed")
    ex:= (2 r**2)**(-6);
    tst:= 1/64 r**(-12) - @(ex);
    assert(tst==0)
    print("Test 03f passed")
    
test03()

def test04():
    __cdbkernel__=create_scope()
    \partial{#}::PartialDerivative;
    t::Coordinate;
    ex:= - 2\frac{\partial_{t}{a**2}**3}{a**3};
    product_rule(_)
    tst:= -16 (a \partial_{t}{a} )**3 a**(-3) - @(ex);
    assert(tst==0)
    print("Test 04 passed")

test04()

def test05():
    __cdbkernel__=create_scope()
    ex:= 2**3;
    expand_power(_)
    tst:= 8 - @(ex);
    assert(tst==0)
    print("Test 05 passed")

test05()


def test06():
    __cdbkernel__=create_scope()
    {t}::Coordinate;
    ex := Q / (f**2 - Q**2);
    substitute(ex, $ f = (Q**2 - \alpha )**(1/2) $)
    tst:= - Q / \alpha - @(ex);
    assert(tst==0)
    print("Test 06 passed")

test06()

        
