Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/random.gi
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ end );
return function(args...)
local filterpos, i, func, info;

if Length(args) < 2 then
ErrorNoReturn("Expected at least 2 arguments, found ", Length(args));
elif IS_CONSTRUCTOR(args[1]) then
ErrorNoReturn("First argument must not be a constructor");
fi;
# Check we understand arguments
# Second value must be an info string
if not IsString(args[2]) then
Expand All @@ -263,7 +268,7 @@ end );

# Info strings always tend to begin 'for ', and here we want
# to be able to edit it, so we check.
if args[2]{[1..23]} <> "for a random source and" then
if Length(args[2]) < 23 or args[2]{[1..23]} <> "for a random source and" then
ErrorNoReturn("Info string must begin 'for a random source and'");
fi;

Expand Down
6 changes: 6 additions & 0 deletions tst/testinstall/method.tst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ gap> List(Concatenation(funcs, ranks), NameFunction);
[ "cheese method", "cheese for a list", "func3",
"Priority calculation for cheese",
"Priority calculation for cheese for a list", "rank3" ]

# Check errors from InstallMethodWithRandomSource for a constructor
gap> DeclareConstructor("TestCons", [IsRandomSource, IsObject]);
gap> InstallMethodWithRandomSource(TestCons, "for a random source and",
> [IsRandomSource, IsObject], ReturnFail);
Error, First argument must not be a constructor
gap> STOP_TEST("method.tst");
Loading