Skip to content

Commit

Permalink
Update TypeOfOperation
Browse files Browse the repository at this point in the history
It now detects setters correctly
  • Loading branch information
markuspf committed Aug 21, 2017
1 parent 8c9aee6 commit d1d1586
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/type.gi
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ end);
InstallGlobalFunction( TypeOfOperation,
function(op)
local type, flags, types, catok, repok, propok, seenprop,
t, flafs, res;
t, res;
if not IsOperation(op) then
ErrorNoReturn("<op> must be an operation");
fi;

type := "Operation";
if IS_IDENTICAL_OBJ(op,IS_OBJECT) then
type := "Filter";
Expand All @@ -159,7 +163,7 @@ function(op)
type := "Filter";
flags := FLAGS_FILTER(op);
if flags <> false then
flags := TRUES_FLAGS(FLAGS_FILTER(op));
flags := TRUES_FLAGS(flags);
types := INFO_FILTERS{flags};
catok := true;
repok := true;
Expand Down Expand Up @@ -187,6 +191,8 @@ function(op)
type := "Representation";
fi;
fi;
elif FLAG1_FILTER(op) > 0 then
class := "Setter";
elif Tester(op) <> false then
# op is an attribute
type := "Attribute";
Expand Down
11 changes: 11 additions & 0 deletions tst/testinstall/type.tst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ gap> test((1,2,3));
gap> test("hello, world");
[ false, false, false, false, false, false ]

gap> test(Setter(IS_MUTABLE_OBJ));
[ false, false, false, false, false, true ]

#
gap> FilterByName("IsCommutative");
<Property "IsCommutative">
Expand All @@ -36,3 +39,11 @@ gap> CategoryByName("IsMagma");
#
gap> ForAll([1..Length(FILTERS)], id -> id = IdOfFilter(FILTERS[id]));
true

gap> ClassOfOperation(IsFilter);
Error, <op> must be an operation

gap> List([IsAbelian, HasIsAbelian, IsMutable, \+, Size, AbelianGroupCons, Setter(IS_MUTABLE_OBJ)], ClassOfOperation);
[ "Property", "Filter", "Category", "Operation", "Attribute", "Constructor", "Setter" ]


0 comments on commit d1d1586

Please sign in to comment.