#
# Test file for QF 0.93
#
# This is a test suite that does some basic checks
# to see that the package is working properly.
#
# If you are using the unix version, run the shell command
#   maple -q < QF_test | more
# and check that the output is a stream of OKAY's.
#
# If you are using the vanilla version, start maple,
# load both the SF and QF packages, then load this file,
# and check that the output is a stream of OKAY's.
#
test:=proc(f,pr) local report;
  assign(evaln(i),i+1); # subversively global
  report:=proc(j) printf(`%3d  OKAY\n`,j) end;
  if nargs=3 then
    if f(op(args[2]))=args[3] then report(i) else args fi
  elif nargs=4 then
    if pr(f(op(args[3])))=args[4] then report(i) else args fi
  elif nargs=5 then
    if pr(op(args[3]))=args[4] then report(i) else args fi
  fi
end:
i:=0:
if assigned(withSF) then withSF() else with(SF) fi:
if assigned(withQF) then withQF() else with(QF) fi:

# DPar
test(DPar,[6], [[6],[5,1],[4,2],[3,2,1]]);
test(DPar,[8,2], [[8],[7,1],[6,2],[5,3]]);
test(DPar,[10,7,3], [[7,3],[7,2,1],[6,4],[6,3,1],[5,4,1],[5,3,2]]);

# OPar
test(OPar,[6], [[5,1],[3,3],[3,1,1,1],[1,1,1,1,1,1]]);
test(OPar,[8,4], [[7,1],[5,3],[5,1,1,1],[3,3,1,1]]);
test(OPar,[11,5,3], [[5,5,1],[5,3,3]]);

# toq
test(toq,[8*p5*p1+5*Q[4,2]], -6*q4*q1^2+2*q2*q3*q1+10*q6+5*q4*q2);
test(toq,[Q[5,2,1],Q], -2*q6*q1^2+q5*q2*q1+2*q7*q1-2*q5*q3+2*q6*q2);

# toddq
test(toddq,[12*q6-8*p1*p5], 2*q1*q5-q1^3*q3+6*q3^2);
test(toddq,[2^7*P[4,2,1],P], 16*q5*q1^2-4*q1^4*q3+q1^7-16*q1*q3^2);

# toddp
test(toddp,[Q[4,2,1],Q], 8/45*p1^7-8/9*p3*p1^4+8/5*p5*p1^2-8/9*p3^2*p1);
test(toddp,[q5+2*P[4,1]], 4/3*p1^2*p3+2/3*p1^5);

# pfaff
test(pfaff,[[8,4,1]], Q[8]*Q[4,1]-Q[4]*Q[8,1]+Q[1]*Q[8,4]);
test(pfaff,[[8,4,3],[3]], Q[5]*Q[4,3]-Q[1]*Q[8,3]+Q[8,4]);

# toQ
test(toQ,[2*p5*Q[3,2]], 2*Q[8,2]-2*Q[7,3]+Q[5,3,2]-Q[4,3,2,1]);
test(toQ,[4*p1^10,nrows=2,'p'],
  2*Q[10]+8*Q[9,1]+27*Q[8,2]+48*Q[7,3]+42*Q[6,4]);

# toP
test(toP,[p7], P[7]-2*P[6,1]+2*P[5,2]-2*P[4,3]);
test(toP,[P[4,3]*P[2,1],DPar(10,6,4)],
  P[6,4]+P[6,3,1]+P[5,4,1]+P[5,3,2]+P[4,3,2,1]);

# super
test(super,[s[3,3,1]],q3^2*q1-q4*q3-q2*q4*q1+q5*q2);

# qf2char
test(qf2char,[q4*p3*p1],30*cl[3,1,1,1,1,1]+12*cl[3,3,1,1]);
test(qf2char,[Q[4,2],Q],4*cl[3,3]-4*cl[3,1,1,1]+40*cl[1,1,1,1,1,1]);

# char2qf
test(char2qf,[cl[5,3,3,1]],2/45*p5*p3^2*p1);
test(char2qf,[10*cl[5,1],Q],2*Q[6]-Q[5,1]+Q[3,2,1]);

# spin
test(spin,[[3,2,1]],
  -2*cl[3,3]+cl[5,1]+4*cl[1,1,1,1,1,1]-cl[3,1,1,1]+3^(1/2)*cl[3,2,1]);

# zeeQ
test(zeeQ, scalar, [toddp(P[6,2,1]),toddp(q3^3),zeeQ],8,0);

if assigned(withQF) then printf(`if OKAY, restart Maple\n`) else quit fi:

