Skip to content

Commit

Permalink
Fix PositionProperty with from < 1
Browse files Browse the repository at this point in the history
  • Loading branch information
James Mitchell committed Jan 3, 2018
1 parent b803d4f commit e11fba9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions tst/testinstall/list.tst
Original file line number Diff line number Diff line change
Expand Up @@ -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");

0 comments on commit e11fba9

Please sign in to comment.