Macaulay2 » Documentation
Packages » Macaulay2Doc :: tests
next | previous | forward | backward | up | index | toc

tests -- locate a package's tests

Synopsis

Description

Returns a hash table containing the tests for the given package. Each key of this hash table is an integer, which would be passed as the first argument of check to run the test. Each value is a TestInput object. These are printed with the location of the file so that you may quickly jump to the source code of the test when using Emacs.

i1 : tests "FirstPackage"

o1 = HashTable{0 => TestInput[../../../../../Macaulay2/packages/FirstPackage.m2:54:1-57:1]}

o1 : HashTable

If the test number is also provided, then the corresponding TestInput object is returned.

i2 : t = tests(0, "FirstPackage")

o2 = TestInput[../../../../../Macaulay2/packages/FirstPackage.m2:54:1-57:1]

o2 : TestInput

The locate and code functions do the expected thing when given a TestInput object.

i3 : locate t

o3 = ../../../../../Macaulay2/packages/FirstPackage.m2:54:1-57:1

o3 : FilePosition
i4 : code t

o4 =  -- /usr/local/share/Macaulay2/FirstPackage.m2:57:1: location of test code

         assert ( firstFunction 2 == "D'oh!" )

Passing only the key of the desired test to code is supported as well.

i5 : code 0

o5 =  -- /usr/local/share/Macaulay2/FirstPackage.m2:57:1: location of test code

         assert ( firstFunction 2 == "D'oh!" )

You may also pass a TestInput object to edit to open the code in your favorite editor.

Ways to use tests :

For the programmer

The object tests is a method function.