Skip to content

Commit

Permalink
Add tests for printing ranges & converting them to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Aug 3, 2022
1 parent fecd8fe commit d8fc20f
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion tst/testinstall/range.tst
Original file line number Diff line number Diff line change
@@ -1,16 +1,84 @@
#@local g,ranges,x,y,z,a,f
#@local TestPrintRangeRep,g,ranges,x,y,z,a,f
gap> START_TEST("range.tst");

#
gap> [0..0];
[ 0 ]
gap> [0..1];
[ 0, 1 ]
gap> [0..2];
[ 0 .. 2 ]
gap> [0,2..2];
[ 0, 2 ]
gap> [0,2..4];
[ 0, 2 .. 4 ]
gap> [0..-1];
[ ]
gap> [0..-2];
[ ]
gap> [0,-1..-1];
[ 0, -1 ]
gap> [0,-1..-2];
[ 0, -1 .. -2 ]
gap> [-5..5];
[ -5 .. 5 ]
gap> [-5,-3..5];
[ -5, -3 .. 5 ]

#
gap> TestPrintRangeRep:=function(r)
> Assert(0, IsRangeRep(r));
> Print("Display: "); Display(r);
> Print("DisplayString: ", DisplayString(r));
> Print("ViewObj: "); ViewObj(r); Print("\n");
> Print("ViewString: ", ViewString(r), "\n");
> Print("PrintObj: ", r, "\n");
> Print("PrintString: ", PrintString(r), "\n");
> Print("String: ", String(r), "\n");
> end;;

#
gap> TestPrintRangeRep([0..1]);
Display: [ 0 .. 1 ]
DisplayString: <object>
ViewObj: [ 0, 1 ]
ViewString: [ 0, 1 ]
PrintObj: [ 0 .. 1 ]
PrintString: [ 0 .. 1 ]
String: [ 0 .. 1 ]
gap> TestPrintRangeRep([0..2]);
Display: [ 0 .. 2 ]
DisplayString: <object>
ViewObj: [ 0 .. 2 ]
ViewString: [ 0, 1, 2 ]
PrintObj: [ 0 .. 2 ]
PrintString: [ 0 .. 2 ]
String: [ 0 .. 2 ]
gap> TestPrintRangeRep([0,2..4]);
Display: [ 0, 2 .. 4 ]
DisplayString: <object>
ViewObj: [ 0, 2 .. 4 ]
ViewString: [ 0, 2, 4 ]
PrintObj: [ 0, 2 .. 4 ]
PrintString: [ 0, 2 .. 4 ]
String: [ 0, 2 .. 4 ]
gap> TestPrintRangeRep([0,-1..-2]);
Display: [ 0, -1 .. -2 ]
DisplayString: <object>
ViewObj: [ 0, -1 .. -2 ]
ViewString: [ 0, -1, -2 ]
PrintObj: [ 0, -1 .. -2 ]
PrintString: [ 0, -1 .. -2 ]
String: [ 0, -1 .. -2 ]
gap> TestPrintRangeRep([0,-1..-1]);
Display: [ 0, -1 .. -1 ]
DisplayString: <object>
ViewObj: [ 0, -1 ]
ViewString: [ 0, -1 ]
PrintObj: [ 0, -1 .. -1 ]
PrintString: [ 0, -1 .. -1 ]
String: [ 0, -1 .. -1 ]

#
gap> 0 in [0..0];
true
Expand Down

0 comments on commit d8fc20f

Please sign in to comment.