Skip to content

Commit

Permalink
Fix IsPackageLoaded & TestPackage to normalize package name
Browse files Browse the repository at this point in the history
For lookup in GAPInfo.PackagesInfo, package names must first
be converted to lowercase.
  • Loading branch information
fingolfin committed May 20, 2020
1 parent bce3fb4 commit 5711862
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ InstallGlobalFunction( IsPackageLoaded, function( name, version... )
result := IsPackageMarkedForLoading( name, version );
if result then
# check if the package actually completed loading
result := GAPInfo.PackagesLoaded.( name )[4];
result := GAPInfo.PackagesLoaded.( LowercaseString( name ) )[4];
fi;
return result;
end );
Expand Down
1 change: 1 addition & 0 deletions lib/test.gi
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ end);
##
InstallGlobalFunction( "TestPackage", function(pkgname)
local testfile, str;
pkgname := LowercaseString(pkgname);
if not IsBound( GAPInfo.PackagesInfo.(pkgname) ) then
Print("#I No package with the name ", pkgname, " is available\n");
return fail;
Expand Down
13 changes: 13 additions & 0 deletions tst/testinstall/package.tst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ gap> TestPackageAvailability("non-existing-package");
fail
gap> TestPackageAvailability("mockpkg");
fail
gap> TestPackageAvailability("MOCKPKG");
fail
gap> TestPackageAvailability("mockpkg", "=0.1");
fail
gap> TestPackageAvailability("mockpkg", ">=0.1");
Expand All @@ -290,6 +292,8 @@ gap> IsPackageLoaded("non-existing-package");
false
gap> IsPackageLoaded("mockpkg");
false
gap> IsPackageLoaded("MOCKPKG");
false
gap> IsPackageLoaded("mockpkg", "=0.1");
false
gap> IsPackageLoaded("mockpkg", ">=0.1");
Expand Down Expand Up @@ -323,6 +327,9 @@ fail
gap> TestPackageAvailability("mockpkg") = Filename(mockpkgpath, "");
oops, should not print here
true
gap> TestPackageAvailability("MOCKPKG") = Filename(mockpkgpath, "");
oops, should not print here
true
gap> TestPackageAvailability("mockpkg", "=0.1") = Filename(mockpkgpath, "");
oops, should not print here
true
Expand All @@ -339,6 +346,8 @@ gap> IsPackageLoaded("non-existing-package");
false
gap> IsPackageLoaded("mockpkg");
false
gap> IsPackageLoaded("MOCKPKG");
false
gap> IsPackageLoaded("mockpkg", "=0.1");
false
gap> IsPackageLoaded("mockpkg", ">=0.1");
Expand Down Expand Up @@ -431,6 +440,8 @@ gap> TestPackageAvailability("non-existing-package");
fail
gap> TestPackageAvailability("mockpkg");
true
gap> TestPackageAvailability("MOCKPKG");
true
gap> TestPackageAvailability("mockpkg", "=0.1");
true
gap> TestPackageAvailability("mockpkg", ">=0.1");
Expand All @@ -445,6 +456,8 @@ gap> IsPackageLoaded("non-existing-package");
false
gap> IsPackageLoaded("mockpkg");
true
gap> IsPackageLoaded("MOCKPKG");
true
gap> IsPackageLoaded("mockpkg", "=0.1");
true
gap> IsPackageLoaded("mockpkg", ">=0.1");
Expand Down

0 comments on commit 5711862

Please sign in to comment.