# This is the source of the test file. The test file is produced by:
# gap4r4 init.g ../if_local < tst/maple.src # on Medicis
# gap_dev init.g < tst/maple.src # on my pc
# remove the line 'gap> LogTo();' at the end of the generated file.


IF_EXEC_FULL_PATH[IF_maple]:="/home/costanti/bin/maple";

LogTo("tst/maple.tst");


# Start

START_TEST( "Test of the 'if' package" );
SizeScreen([80]);;


IF_Interface(IF_maple, "gcd", [1000, 360] );


# `..`

IF_Type(IF_maple, [-5..3]);
IF_ConvertFromGap(IF_maple, [-5..3]);
IF_Interface(IF_maple, "", [[-5..3]]);


# integer

l := [-11^120, -1, 0, 1, 10^120];;
List(l, x->IF_Type(IF_maple, x));
l=List(l, x-> IF_Interface(IF_maple, "", [x]));


# string

l := Difference([0..255], IF_PROHIBITED_CHARS[IF_maple]);;
l1:= List( l{[1..110]}, CHAR_INT);;
l2:= List( l{[110..Length(l)]}, CHAR_INT);;
for i in [l1,l2] do
    ConvertToStringRep( i );
    if not i=IF_Interface(IF_maple, "", [i]) then
        Print( "different strings!\n" );
    fi;
od;


# list

l:=[ [ 2 .. 5 ], 53, "ciao", [ 1, 2, 4 ], 33/4 ];;
l=IF_Interface(IF_maple, "", [l] );
[]=IF_Interface(IF_maple, "", [[]]); # empty list


# exprseq

IF_Interface(IF_maple, "whattype", "1,2,3");
IF_Interface(IF_maple, "", "1,2,3");


# boolean

IF_Interface(IF_maple, "not", [true] );
IF_Interface(IF_maple, "not", [false] );
IF_Interface(IF_maple, "FAIL or", [false] );


# rational

c:=Enumerator(Rationals);
for i in [1..20] do
  if not c[i]=IF_Interface(IF_maple, "", [c[i]] ) then
    Print( c[i], " ", fail, "\n");
  fi;
od;


# complex

Print( "imaginary unit ", IF_Interface(IF_maple, "", [E(4)] ), "\n" );
c:=Enumerator(GaussianRationals);
for i in [1..50] do
  if not c[i]=IF_Interface(IF_maple, "", [c[i]] ) then
    Print( i, " ", c[i], " ", fail, "\n");
  fi;
od;
root_10_2 := IF_Interface(IF_maple, "root", [10,2]);
root_10_2^2=10;


# extended_numeric

infinity = IF_Interface(IF_maple, "", [infinity]);


# polynom

R:=PolynomialRing(Rationals, 4);;
g:=GeneratorsOfLeftOperatorRingWithOne(R);;
p1:=g[1]*g[3]^3-12*g[2]*g[4]*g[1]^4;;
p1=IF_Interface(IF_maple, "", [p1] );

x:=Indeterminate(Rationals);;
y:=Indeterminate(Rationals,[x]);;
IF_Interface(IF_maple, "PolynomialTools[MinimalPolynomial]", [4+E(4),6]) =
IF_MAPLE__X^2-8*IF_MAPLE__X+17;
IF_Interface(IF_maple, "solve", [x^2+4*x+1]);
IF_Interface(IF_maple, "solve", [x^2+4*x+y,x-y]);


# ratpoly

q:= g[2]^3*g[3]^2+4*g[1]+g[4]^6-8;;
r1 :=p1/q;;
r1=IF_Interface(IF_maple, "", [r1] );


# SDMPolynom

IF_Interface(IF_maple, "", "x_1^3+5*x_1^2+11*x_1+15")= 
IF_Interface(IF_maple, "", "SDMPolynom(x_1^3+5*x_1^2+11*x_1+15,x_1)");


# float

IF_Interface(IF_maple, "fsolve", [x^2+4*x+1]);


# Matrix

m:=[[11,12,13],[21,22,23]];
IF_ConvertFromGap( IF_maple,m);
m=IF_Interface( IF_maple,"",[m]);

m:=[[11/5]];
IF_ConvertFromGap( IF_maple,m);
m=IF_Interface( IF_maple,"",[m]);

m:=[[11/5,12/5,13/5],[21/5,22/5,23/5]];
IF_ConvertFromGap( IF_maple,m);
m=IF_Interface( IF_maple,"",[m]);

m:=[[ 4*g[1]*g[3]^2, -g[2]-g[4]],
 [ E(4)*g[1]+g[1]^2*g[2]^3, (-1-E(4))*g[3]-2*(1+E(4))*g[4]]];;
m=IF_Interface( IF_maple,"",[m]);

IF_Interface( IF_maple, "", [EmptyMatrix(0)] )=EmptyMatrix(0);

# Vector[row]

m:=[11,12,13,21,22,23];
IF_ConvertFromGap( IF_maple,m);
m=IF_Interface( IF_maple,"",[m]);

m:= [p1,q,r1];;
m=IF_Interface( IF_maple,"",[m]);



# end of test file

STOP_TEST( "test", 10000 );

LogTo();
quit;
