From 57118629075626f42778d971b2bde50025c23b1a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 21 May 2020 01:06:51 +0200 Subject: [PATCH] Fix IsPackageLoaded & TestPackage to normalize package name For lookup in GAPInfo.PackagesInfo, package names must first be converted to lowercase. --- lib/package.gi | 2 +- lib/test.gi | 1 + tst/testinstall/package.tst | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/package.gi b/lib/package.gi index 435bd2d5c1..bbab34779c 100644 --- a/lib/package.gi +++ b/lib/package.gi @@ -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 ); diff --git a/lib/test.gi b/lib/test.gi index 2f4317933d..472c1690f0 100644 --- a/lib/test.gi +++ b/lib/test.gi @@ -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; diff --git a/tst/testinstall/package.tst b/tst/testinstall/package.tst index 20c32d032c..4b01a92185 100644 --- a/tst/testinstall/package.tst +++ b/tst/testinstall/package.tst @@ -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"); @@ -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"); @@ -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 @@ -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"); @@ -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"); @@ -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");