Skip to content

Commit b190ace

Browse files
committed
Have packageFiles return empty list for packages w/o files
In particular, packages defined in startup.m2 (currently just User), stdio, or currentString. This was also causing a problem with "check User", which was running into this issue via "needsPackage", so we add a unit test
1 parent d389731 commit b190ace

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

M2/Macaulay2/m2/packages.m2

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,15 @@ debug GlobalDictionary := dict -> (
553553
checkShadow())
554554

555555
packageFiles = pkg -> (
556-
pkgaux := (
556+
srcfile := realpath pkg#"source file";
557+
if (
558+
srcfile == "stdio" or
559+
srcfile == "currentString" or
560+
match("/startup\\.m2(?:\\.in)?$", srcfile))
561+
then {}
562+
else prepend(srcfile,
557563
if not pkg#?"auxiliary files" then {}
558-
else select(values loadedFiles, match_(pkg#"auxiliary files")));
559-
prepend(realpath pkg#"source file", pkgaux))
564+
else select(values loadedFiles, match_(pkg#"auxiliary files"))))
560565

561566
locate Package := pkg -> NumberedVerticalList (
562567
-- TODO: somehow keep track of the number of lines of each file

M2/Macaulay2/tests/normal/testing.m2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ expectedCode = DIV{
2121
assert BinaryOperation(symbol ===, code pkgtest, expectedCode)
2222
assert BinaryOperation(symbol ===, code 0, expectedCode)
2323

24+
TEST "assert Equation(1 + 1, 2)"
25+
check User
26+
2427
assert( (for i from 1 to 2 list { for j from 1 to 2 do { if j == 2 then break 444; } }) === {{444}, {444}} ) -- see issue #2522
2528

2629

0 commit comments

Comments
 (0)