Skip to content
Merged
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
30 changes: 23 additions & 7 deletions lib/oper.g
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,17 @@ end );
##
## <#GAPDoc Label="TraceImmediateMethods">
## <ManSection>
## <Func Name="TraceImmediateMethods" Arg='flag'/>
## <Func Name="TraceImmediateMethods" Arg='[flag]'/>
## <Func Name="UntraceImmediateMethods" Arg=''/>
##
## <Description>
## If <A>flag</A> is true, tracing for all immediate methods is turned on.
## If <A>flag</A> is false it is turned off.
## <Ref Func="TraceImmediateMethods"/> enables tracing for all immediate methods
## if <A>flag</A> is either <K>true</K>, or not present.
## <Ref Func="UntraceImmediateMethods"/>, or <Ref Func="TraceImmediateMethods"/>
## with <A>flag</A> equal <K>false</K> turns tracing off.
## (There is no facility to trace <E>specific</E> immediate methods.)
## <Example><![CDATA[
## gap> TraceImmediateMethods( true );
## gap> TraceImmediateMethods( );
## gap> g:= Group( (1,2,3), (1,2) );;
## #I immediate: Size
## #I immediate: IsCyclic
Expand All @@ -488,7 +491,7 @@ end );
## #I immediate: IsPerfectGroup
## #I immediate: IsEmpty
## 6
## gap> TraceImmediateMethods( false );
## gap> UntraceImmediateMethods( );
## gap> UntraceMethods( [ Size ] );
## ]]></Example>
## <P/>
Expand All @@ -507,8 +510,21 @@ end );
##
TRACE_IMMEDIATE_METHODS := false;

BIND_GLOBAL( "TraceImmediateMethods", function( flag )
if flag then
BIND_GLOBAL( "UntraceImmediateMethods", function ()
TRACE_IMMEDIATE_METHODS := false;
end );

BIND_GLOBAL( "TraceImmediateMethods", function( arg )
if LENGTH(arg) = 0 then
TRACE_IMMEDIATE_METHODS := true;
return;
fi;

if LENGTH(arg) > 1 or not IS_BOOL(arg[1]) then
Error("Usage: TraceImmediateMethods( [bool] )");
fi;

if arg[1] then
TRACE_IMMEDIATE_METHODS := true;
else
TRACE_IMMEDIATE_METHODS := false;
Expand Down
21 changes: 21 additions & 0 deletions tst/testinstall/trace.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
gap> START_TEST("trace.tst");
gap> g:= Group( (1,2,3), (1,2) );;
gap> TraceImmediateMethods( );
gap> g:= Group( (1,2,3), (1,2) );;
#I immediate: Size
#I immediate: IsCyclic
#I immediate: IsCommutative
#I immediate: IsTrivial
gap> UntraceImmediateMethods();
gap> g:= Group( (1,2,3), (1,2) );;
gap> TraceImmediateMethods( true );
gap> g:= Group( (1,2,3), (1,2) );;
#I immediate: Size
#I immediate: IsCyclic
#I immediate: IsCommutative
#I immediate: IsTrivial
gap> TraceImmediateMethods( false );
gap> g:= Group( (1,2,3), (1,2) );;
gap> TraceImmediateMethods( "cheese" );
Error, Usage: TraceImmediateMethods( [bool] )
gap> STOP_TEST("trace.tst", 1);