From aac1175f06e4643cb65913598b7d88354ff5ff8c Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Sat, 4 Apr 2020 11:32:14 +0100 Subject: [PATCH] Fix error checking in PartialPerm --- lib/pperm.gi | 4 ++-- tst/testinstall/pperm.tst | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/lib/pperm.gi b/lib/pperm.gi index 9344cb7d9f..a250f718ab 100644 --- a/lib/pperm.gi +++ b/lib/pperm.gi @@ -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 diff --git a/tst/testinstall/pperm.tst b/tst/testinstall/pperm.tst index d5e4e75635..fb6c7db002 100644 --- a/tst/testinstall/pperm.tst +++ b/tst/testinstall/pperm.tst @@ -3317,9 +3317,41 @@ gap> MultiplicativeZeroOp(x); gap> MultiplicativeZero(x); -# 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