From e11fba95487b625e3a81145fe278a091a9662d6d Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Mon, 1 Jan 2018 15:04:25 +0000 Subject: [PATCH] Fix PositionProperty with from < 1 --- lib/list.gi | 8 ++++---- tst/testinstall/list.tst | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/list.gi b/lib/list.gi index acfad272058..362b250674e 100644 --- a/lib/list.gi +++ b/lib/list.gi @@ -1525,8 +1525,8 @@ InstallMethod( PositionProperty, function( list, func, from ) local i; - if from < 1 then - from:= 1; + if from < 0 then + from:= 0; fi; for i in [ from+1 .. Length( list ) ] do if IsBound( list[i] ) then @@ -1557,8 +1557,8 @@ InstallMethod( PositionProperty, function( list, func, from ) local i; - if from < 1 then - from:= 1; + if from < 0 then + from:= 0; fi; for i in [ from+1 .. Length( list ) ] do if func( list[i] ) then diff --git a/tst/testinstall/list.tst b/tst/testinstall/list.tst index 95d4f6e07a4..743c1008b4f 100644 --- a/tst/testinstall/list.tst +++ b/tst/testinstall/list.tst @@ -209,5 +209,25 @@ gap> PositionsProperty( ll, ReturnTrue ); gap> PositionsProperty( ll, IsInt ); [ 1, 2, 3 ] +# PositionProperty +gap> ll := [ 1, , "s" ];; +gap> PositionProperty( ll, ReturnTrue, 0); +1 +gap> PositionProperty( ll, ReturnTrue, 1); +3 +gap> PositionProperty( ll, IsInt, 0); +1 +gap> PositionProperty( ll, IsInt, 1); +fail +gap> ll := [ 1, 2, 3 ];; +gap> PositionProperty( ll, ReturnTrue, 0); +1 +gap> PositionProperty( ll, ReturnTrue, 1); +2 +gap> PositionProperty( ll, ReturnTrue, 2); +3 +gap> PositionProperty( ll, ReturnTrue, 3); +fail + # gap> STOP_TEST("list.tst");