Skip to content

Commit

Permalink
Fix error checking in PartialPerm
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson authored and fingolfin committed Apr 13, 2020
1 parent 569d9bc commit aac1175
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/pperm.gi
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ function(arg)
"duplicate-free,");
fi;
elif Length(arg) = 2 then
if IsSSortedList(arg[1]) and ForAll(arg[1], IsSmallIntRep)
and IsDuplicateFreeList(arg[2]) and ForAll(arg[2], IsSmallIntRep)
if IsSSortedList(arg[1]) and ForAll(arg[1], IsPosInt and IsSmallIntRep)
and IsDuplicateFreeList(arg[2]) and ForAll(arg[2], IsPosInt and IsSmallIntRep)
and Length(arg[1]) = Length(arg[2]) then
return SparsePartialPermNC(arg[1], arg[2]);
else
Expand Down
34 changes: 33 additions & 1 deletion tst/testinstall/pperm.tst
Original file line number Diff line number Diff line change
Expand Up @@ -3317,9 +3317,41 @@ gap> MultiplicativeZeroOp(x);
gap> MultiplicativeZero(x);
<empty partial perm>
# Test PartialPerm (for sparse incorrect arg)
# Test PartialPerm
gap> PartialPerm([1,2,8],[3,4,1,2]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([0,1],[2,3]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([2,3],[0,1]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([-2,-3],[5,6]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([5,6],[-2,-3]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([5,2^100], [5,6]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([5,6],[5,2^100]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([5,5],[5,6]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
gap> PartialPerm([5,6],[5,5]);
Error, usage: the 1st argument must be a set of positive integers and the 2nd \
argument must be a duplicate-free list of positive integers of equal length to\
the first
Expand Down

0 comments on commit aac1175

Please sign in to comment.