Skip to content

Commit

Permalink
Add test for GAPInfo.Date format (#5757)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Jul 1, 2024
1 parent 1a9d941 commit 81659b1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 3 additions & 5 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ Unicode:= "dummy";
Encode:= "dummy";

InstallGlobalFunction( BibEntry, function( arg )
local key, pkgname, pkginfo, GAP, ps, months, val, entry, author;
local key, pkgname, pkginfo, GAP, ps, val, entry, author;

key:= false;
if Length( arg ) = 1 and IsString( arg[1] ) then
Expand Down Expand Up @@ -2771,13 +2771,11 @@ InstallGlobalFunction( BibEntry, function( arg )
# We put the version information into the <C>title</C> component since
# the <C>edition</C> component is not supported in the base styles.

months:= [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
if GAP then
val:= SplitString( GAPInfo.Date, "-" );
if Length( val ) = 3 then
if Int( val[2] ) in [ 1 .. 12 ] then
val:= Concatenation( " <month>", months[ Int( val[2] ) ],
val:= Concatenation( " <month>", NameMonth[ Int( val[2] ) ],
"</month>\n <year>", val[1], "</year>\n" );
else
val:= Concatenation( " <month>", val[2],
Expand Down Expand Up @@ -2831,7 +2829,7 @@ InstallGlobalFunction( BibEntry, function( arg )
and Length( pkginfo.Date ) = 10 then
if Int( pkginfo.Date{ [ 4, 5 ] } ) in [ 1 .. 12 ] then
Append( entry, Concatenation(
" <month>", months[ Int( pkginfo.Date{ [ 4, 5 ] } ) ],
" <month>", NameMonth[ Int( pkginfo.Date{ [ 4, 5 ] } ) ],
"</month>\n",
" <year>", pkginfo.Date{ [ 7 .. 10 ] }, "</year>\n" ) );
else
Expand Down
2 changes: 1 addition & 1 deletion src/version.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char * SyKernelVersion = "@GAP_VERSION@";
**
*V SyReleaseDay . . . . . . . . . . . . . . release date of this GAP version
**
** 'SyReleaseDay' is the date of the release, e.g. "19-Jun-2019"; for
** 'SyReleaseDay' is the date of the release, e.g. "2019-Jun-19"; for
** development versions, this is set to "today".
*/
const char * SyReleaseDay = "@GAP_RELEASEDAY@";
Expand Down
2 changes: 1 addition & 1 deletion src/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extern const char * SyKernelVersion;
**
*V SyReleaseDay . . . . . . . . . . . . . . release date of this GAP version
**
** 'SyReleaseDay' is the date of the release, e.g. "19-Jun-2019"; for
** 'SyReleaseDay' is the date of the release, e.g. "2019-Jun-19"; for
** development versions, this is set to "today".
*/
extern const char * SyReleaseDay;
Expand Down
17 changes: 16 additions & 1 deletion tst/testinstall/package.tst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#@local entry,equ,pair,sml,oldTermEncoding,pkginfo,info,tmp_dir,mockpkgpath,old_warning_level,p,n,filename
#@local entry,equ,pair,sml,oldTermEncoding,pkginfo,info,tmp_dir,mockpkgpath,old_warning_level,p,n,filename,IsDateFormatValid
gap> START_TEST("package.tst");

# CompareVersionNumbers( <supplied>, <required>[, \"equal\"] )
Expand Down Expand Up @@ -516,6 +516,21 @@ new methods:
mockpkg_Property( ... )*


# Cite() expects GAPInfo.Date to be of the form "YYYY-MM-DD" or "YYYY-Mon-DD" (or "today")
gap> IsDateFormatValid := function( datestring )
> local val;
> if datestring = "today" then
> return true;
> fi;
> val:= SplitString( datestring, "-" );
> if Length( val ) <> 3 then
> return false;
> fi;
> return Int( val[1] ) in [ 1900 .. 2100 ] and ( val[2] in NameMonth or Int( val[2] ) in [ 1 .. 12 ] ) and Int( val[3] ) in [ 1 .. 31 ];
> end;;
gap> IsDateFormatValid( GAPInfo.Date );
true

# Test the Cite() command (output changed with GAPDoc 1.6.6 and again with 1.6.7)
#@if CompareVersionNumbers(InstalledPackageVersion("gapdoc"), "1.6.7")
gap> Cite("mockpkg");
Expand Down

0 comments on commit 81659b1

Please sign in to comment.