ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_test Module Reference

This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMonte library. More...

Data Types

type  dir_type
 This is the module private derived type for constructing objects that contain the input and output directory paths for tests. More...
 
type  file_type
 This is the module private derived type for constructing objects that contain the path to a file and its unit. More...
 
type  func_type
 
type  scope_type
 
interface  test_type
 This is the derived type test_type for generating objects that facilitate testing of a series of procedures or concepts within a unified testing framework. More...
 

Functions/Subroutines

subroutine setInitial ()
 Initialize the global module variables for testing.
More...
 
subroutine setSummary ()
 Summarize the collection of all tests performed on all modules (or scoping units).
More...
 
type(test_type) function test_typer (host, inp, out, traceable)
 Generate and return an object of type test_type. More...
 
subroutine setTestFunc (self, getAssertion, name)
 Run the input test function and verify the assertion returned by the test function. More...
 
subroutine setTestAsserted (self, assertion, desc, line)
 Test the validity of the input assertion and if it does not hold,
More...
 
subroutine setTestSummary (self)
 Summarize the suite of tests performed by the parent object of type test_type of this method. More...
 

Detailed Description

This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMonte library.

Tests within the ParaMonte testing framework are based on modules.
Each module pm_* has a corresponding test module test_pm_* that implements tests of all objects and routines of the target module.
Each test module must contain a public subroutine named setTest() with the following interface,

subroutine setTest()
end subroutine

within which all test are implemented as desired.
These module subroutines are subsequently called in the ParaMonte main.F90 file.
See the documentation of test_type for further details on the testing approach and assertion verification.

See also
pm_err


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Function/Subroutine Documentation

◆ setInitial()

subroutine pm_test::setInitial

Initialize the global module variables for testing.

This subroutine is called internally by the procedures of this module and methods of objects of type test_type at the beginning of the first test, before any testing is done to ensure information for the final global summary by setSummary is properly collected.


Possible calling interfaces

call setInitial()
See also
test_type
setSummary


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 260 of file pm_test.F90.

Referenced by setSummary(), and pm_test::test_type::test_typer().

Here is the caller graph for this function:

◆ setSummary()

subroutine pm_test::setSummary

Summarize the collection of all tests performed on all modules (or scoping units).

Calling this procedure at the end of a series of tests performed by a collection of objects of type test_type will lead to display of relevant summary of all passed and failed tests performed and further details about the failed tests and test timing.


Possible calling interfaces

call setSummary()
Warning
This procedure must be called by all parallel images/processes/threads.
See also
test_type
setInitial


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 307 of file pm_test.F90.

References setInitial(), and pm_io::TABEQV.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTestAsserted()

subroutine pm_test::setTestAsserted ( class(test_type), intent(inout)  self,
logical(LK), intent(in)  assertion,
character(*, SK), intent(in), optional  desc,
integer(IK), intent(in), optional  line 
)

Test the validity of the input assertion and if it does not hold,

  1. in debug and testing modes, call error stop after displaying the assertion description desc.
  2. in release mode, report the test failure and continue with the rest of the tests.

This procedure is a method of the class test_type.

Parameters
[in,out]self: The input/output object of class test_type that is passed implicitly.
[in]assertion: The input scalar of type logical of default kind LK containing the assertion to be verified.
[in]desc: The input scalar of type character of default kind SK of arbitrary length type parameter containing a description of assertion for display if the assertion fails and selftraceable is .true..
(optional, default = "unavailable")
[in]line: The input scalar of type integer of default kind IK, containing the line number for the source of the assertion within the test.
Supplying this information helps trace the source of the test failure should it occur.
(optional)


Possible calling interfaces

use pm_test, only: test_type
type(test_type) :: test
test = test_type()
call test%run(assertion = assertion, desc = desc, line = line)
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209
See also
test_type


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, April 20, 2015, 1:11 AM, National Institute for Fusion Studies, The University of Texas at Austin

Definition at line 592 of file pm_test.F90.

◆ setTestFunc()

subroutine pm_test::setTestFunc ( class(test_type), intent(inout)  self,
procedure(logical(LK))  getAssertion,
character(*, SK), intent(in), optional  name 
)

Run the input test function and verify the assertion returned by the test function.

This procedure is a method of test_type.
See also the documentation of test_type.

Parameters
[in,out]self: The input/output object of class test_type that is passed implicitly.
getAssertion: The external user-specified test function that takes no input arguments and returns a scalar of type logical of default kind LK.
The returned value must be .true. if and only if the test assertion is verified within the specified test function.
The following illustrates the generic interface of getAssertion(),
function getAssertion() result(assertion)
use pm_kind, only: LK
logical(LK) :: assertion
end function
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
[in]name: The input scalar of type character of default kind SK containing the name of the test function as is, that is, the actual name of target of the dummy argument getAssertion().
The test function name is assumed to follow the template test_*() or test_*_ID() where,
  1. * is taken as the name of the target procedure that is being tested.
    This name is used for displaying testing details on the specified output.
  2. ID is the optional integer in test function name representing the ID of the current test function for the target procedure being tested.
    The default value for ID is 1, if missing.
If the specified function name is not prefixed with test_, the whole name (excluding any ID suffix) is taken as the name of the procedure being tested.
(optional, default = SK_"@test_unknown".)


Possible calling interfaces

use pm_test, only: test_type
type(test_type) :: test
test = test_type()
call test%run(getAssertion, name = name)
Remarks
The procedures under discussion are impure.
See also
test_type


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Tuesday March 7, 2017, 3:50 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 508 of file pm_test.F90.

◆ setTestSummary()

subroutine pm_test::setTestSummary ( class(test_type), intent(inout)  self)

Summarize the suite of tests performed by the parent object of type test_type of this method.

This procedure is a method of test_type.
See also the documentation of test_type.
This procedure can be effectively considered as the destructor of an object of type test_type.

Parameters
[in,out]self: The input/output scalar object of class test_type that is to be destructed.
Warning
This method must be called by all images/processes/threads as it contains a global synchronization upon exit.
Remarks
The procedures under discussion are impure.
See also
test_type


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Tuesday March 7, 2017, 3:50 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 682 of file pm_test.F90.

◆ test_typer()

type(test_type) function pm_test::test_typer ( character(*, SK), intent(in), optional  host,
character(*, SK), intent(in), optional  inp,
character(*, SK), intent(in), optional  out,
logical(LK), intent(in), optional  traceable 
)

Generate and return an object of type test_type.

This procedure is a constructor of test_type.
See also the documentation of test_type.

Parameters
[in]host: The input scalar of type character of default kind SK containing the name of the host of the procedure or code that is being tested.
Frequently, in modern Fortran, this is the name of the module containing the procedure being tested.
This name is used only for information display purposes.
(optional, default = SK_"@unknown_scope", that is, the target procedures to be tested are assumed to be external and not in a module or in any specific host scope.)
[in]inp: The input scalar of type character of arbitrary length type parameter, containing the input directory for the current testing suite (i.e., all tests performed with the output object of this constructor).
The specified value for this argument filles the corresponding inp component of the dir component of the output test object.
(optional, default = SK_"./input")
[in]out: The input scalar of type character of arbitrary length type parameter, containing the output directory for the current testing suite (i.e., all tests performed with the output object of this constructor).
The specified value for this argument filles the corresponding out component of the out component of the output test object.
(optional, default = SK_"./output")
[in]traceable: The input scalar of type logical of default kind LK, that can be used to control the display of debugging information for failed tests.
Specifying this argument directly sets the corresponding traceable component of the output test object.
By convention, setting traceable to .true. is used within the test implementations to allow displaying information about assertion failures should any occur.
The ability to display descriptive information about the source of a test failure and its origins if often desired at the time of debugging.
Therefore, this component is set to .true. when runtime checks are enabled (i.e., FFP macro CHECK_ENABLED=1 is set, frequently corresponding to the debug mode) and .false. otherwise (frequently corresponding to the release mode).
This optional input argument overrides the default behavior.
Note that if traceable is set to .true._LK, the program will error stop by encountering the first test failure.
(optional, default = .true._LK if the library is built with preprocessor macro CHECK_ENABLED=1, otherwise .false._LK)
Returns
test : The output scalar object of type test_type containing the specifics of the runtime system shell.


Possible calling interfaces

use pm_test, only: test_type
type(test_type) :: test
test = test_type(host = host, inp = inp, out = out, traceable = traceable)
Warning
This procedure must be called by all images/processes in parallel mode as it contains a call to image_type()%sync()`.
Remarks
The procedures under discussion are impure.
See also
test_type


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Tuesday March 7, 2017, 3:50 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas at Austin

Definition at line 412 of file pm_test.F90.