Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Pfeiffer committed Aug 17, 2018
1 parent c7173a2 commit 579d428
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ testbugfix: all
tee `date -u +dev/log/testbugfix2_%Y-%m-%d-%H-%M` )

testlibgap: libgap.la obj/tst/testlibgap/basic.lo
$(QUIET_LINK)$(LINK) obj/tst/testlibgap/basic.lo libgap.la -o test-libgap
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) obj/tst/testlibgap/basic.lo libgap.la -o test-libgap
./test-libgap -l $(top_srcdir) -m 32m -q -T > basic.out
diff $(top_srcdir)/tst/testlibgap/basic.expect basic.out
.PHONY: testlibgap
Expand Down
35 changes: 12 additions & 23 deletions tst/testlibgap/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,33 @@ void test_eval(const char * cmd)
Obj res, ires;
Int rc, i;

printf("Input:\n%s", cmd);
printf("gap> %s\n", cmd);
res = GAP_EvalString(cmd);
rc = GAP_LenPList(res);
for(i=1;i<=rc;i++) {
ires = GAP_ElmPList(res, i);
if( GAP_ElmPList(ires, 1) == True )
printf("Output:\n%s\n", CSTR_STRING(GAP_ElmPList(ires, 5)));
printf("%s\n", CSTR_STRING(GAP_ElmPList(ires, 5)));
}
}

int main(int argc, char **argv)
{
printf("Initializing GAP...\n");
printf("# Initializing GAP...\n");
GAP_Initialize(argc, argv, environ, 0L, 0L);
printf("done\n");

CollectBags(0, 1); // full GC

test_eval("1+2+3;\n");
test_eval("g:=FreeGroup(2);\n");
test_eval("a:=g.1;\n");
test_eval("b:=g.2;\n");
test_eval("lis:=[a^2, a^2, b*a];\n");
test_eval("h:=g/lis;\n");
test_eval("c:=h.1;\n");
test_eval("Set([1..1000000], i->Order(c));\n");
test_eval("1+2+3;");
test_eval("g:=FreeGroup(2);");
test_eval("a:=g.1;");
test_eval("b:=g.2;");
test_eval("lis:=[a^2, a^2, b*a];");
test_eval("h:=g/lis;");
test_eval("c:=h.1;");
test_eval("Set([1..1000000], i->Order(c));");

GAP_Finalize();
printf("# done\n");
return 0;
}


/*
g:=FreeGroup(2);
a:=g.1;
b:=g.2;
lis:=[a^2, a^2, b*a];
h:=g/lis;
c:=h.1;
Set([1..300000], i->Order(c));
*/
36 changes: 10 additions & 26 deletions tst/testlibgap/basic.expect
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
Initializing GAP...
done
Input:
1+2+3;
Output:
# Initializing GAP...
gap> 1+2+3;
6
Input:
g:=FreeGroup(2);
Output:
gap> g:=FreeGroup(2);
<free group on the generators [ f1, f2 ]>
Input:
a:=g.1;
Output:
gap> a:=g.1;
f1
Input:
b:=g.2;
Output:
gap> b:=g.2;
f2
Input:
lis:=[a^2, a^2, b*a];
Output:
gap> lis:=[a^2, a^2, b*a];
[ f1^2, f1^2, f2*f1 ]
Input:
h:=g/lis;
Output:
gap> h:=g/lis;
<fp group on the generators [ f1, f2 ]>
Input:
c:=h.1;
Output:
gap> c:=h.1;
f1
Input:
Set([1..1000000], i->Order(c));
Output:
gap> Set([1..1000000], i->Order(c));
[ 2 ]
# done

0 comments on commit 579d428

Please sign in to comment.