-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd17292
commit 3ac8fb0
Showing
4 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
gap> START_TEST("BindingsOfClosure"); | ||
|
||
# Test bad input | ||
gap> BindingsOfClosure(0); | ||
Error, ENVI_FUNC: <func> must be a function (not the integer 0) | ||
|
||
# Test some boundary cases | ||
gap> BindingsOfClosure(IsInt); # category | ||
fail | ||
gap> BindingsOfClosure(IsCommutative); # property | ||
fail | ||
gap> BindingsOfClosure(DerivedSubgroup); # attribute | ||
fail | ||
gap> BindingsOfClosure(ENVI_FUNC); # kernel function | ||
fail | ||
gap> BindingsOfClosure(INSTALL_METHOD); # gac compiled function | ||
rec( ) | ||
|
||
# function with no bindings | ||
gap> makeFun:=n -> x -> x + n;; | ||
gap> BindingsOfClosure(makeFun); | ||
rec( ) | ||
|
||
# simple binding | ||
gap> f:=makeFun(42);; | ||
gap> BindingsOfClosure(f); | ||
rec( n := 42 ) | ||
gap> Display(f); | ||
function ( x ) | ||
return x + n; | ||
end | ||
|
||
# real world example from the library | ||
gap> f := ApplicableMethod( OrbitsDomain, [ SymmetricGroup(5), [1..5] ] );; | ||
gap> BindingsOfClosure(f); | ||
rec( NewAorP := function( name, filter, args... ) ... end, | ||
name := "OrbitsDomain", op := <Attribute "OrbitsDomain">, | ||
reqs := [ <Filter "(IsMagmaWithInverses and IsAssociative)">, | ||
<Category "IsListOrCollection">, <Category "IsList">, | ||
<Category "IsList">, <Category "IsFunction"> ], usetype := false ) | ||
gap> Display(f); | ||
function ( G, D ) | ||
if D = MovedPoints( G ) then | ||
return op( G ); | ||
else | ||
TryNextMethod(); | ||
fi; | ||
return; | ||
end | ||
|
||
# | ||
gap> STOP_TEST("BindingsOfClosure"); |