Skip to content

Commit

Permalink
Document check(TestInput) and friends
Browse files Browse the repository at this point in the history
We also update the "check" docs to use actual examples instead of
canned examples.  We use FirstPackage tests since it should be
installed prior to Macaulay2Doc.  We also add one more test to
FirstPackage to make these examples slightly more interesting.
  • Loading branch information
d-torrance committed Feb 18, 2025
1 parent e8d2cc1 commit f5ebfc7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
4 changes: 4 additions & 0 deletions M2/Macaulay2/packages/FirstPackage.m2
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ TEST ///
assert ( firstFunction 2 == "D'oh!" )
///

TEST ///
assert ( firstFunction 1 == "Hello World!" )
///

end--

You can write anything you want down here. I like to keep examples
Expand Down
39 changes: 28 additions & 11 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/check-doc.m2
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Node
(check, ZZ, String)
(check, List, Package)
(check, List, String)
(check, List)
(check, TestInput)
(check, ZZ)
[check, UserMode]
[check, Verbose]
Headline
Expand All @@ -52,8 +55,8 @@ Node
check(i, pkg)
check(L, pkg)
Inputs
pkg:Package
or String, the package to test
pkg:{Package,String}
the package to test
i:ZZ
the index of a test to run
L:List
Expand All @@ -79,19 +82,32 @@ Node
One provides tests using the @TO symbol TEST@ function following the @TO beginDocumentation@ call in the source
of the package.

Optionally, one can store all tests in a @TT "tests.m2"@ directory under the auxiliary subdirectory of
Optionally, one can store all tests in a @TT "tests.m2"@ file under the auxiliary subdirectory of
the package and load the file from the main package source file.

For example, to run the tests for the @TO "LLLBases :: LLLBases"@ package (Lenstra-Lenstra-Lovasz bases), use:
CannedExample
needsPackage "LLLBases"
check_1 LLLBases
check LLLBases
For example, to run the tests for the @TO "FirstPackage::FirstPackage"@ package, use:
Example
needsPackage "FirstPackage" -* no-capture-flag *-
check_1 FirstPackage
check FirstPackage
Text
Alternatively, if the package is installed somewhere accessible, one can do the following.
CannedExample
check_1 "LLLBases"
check "LLLBases"
Example
check_1 "FirstPackage"
check "FirstPackage"
Text
A @TO TestInput@ object (or a list of such objects) can also be run directly.
Example
tests(1, "FirstPackage")
check oo
tests "FirstPackage"
check oo
Text
If only an integer is passed as an argument, then the test with that index from the last call to @TO tests@
is run.
Example
tests "FirstPackage"
check 1
Caveat
Currently, if the package was only partially loaded because the documentation was
obtainable from a database (see @TO "beginDocumentation"@), then the package will be reloaded,
Expand All @@ -104,4 +120,5 @@ Node
symbol TEST
installPackage
loadPackage
tests
///

0 comments on commit f5ebfc7

Please sign in to comment.