diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e498c5aa248f6d46a3fce235390c58b97f07ccb9..26d690a460433014701db3dd53c074e1e0d6a6da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,10 +102,10 @@ It's useful to contribute `.mod` files that test some aspect of Dynare that is n So-called unitary tests allow the test suite to check the correct functioning of the Matlab functions contained in Dynare. To add a unitary test you need to 1. add the keyword ` % --*-- Unitary tests --*--` at the end of the `function` header to tell the testsuite that the file contains unitary tests. -1. Add the particular tests at the end of the file (either after a `return` or the closing `end`) by - a. Starting a test with `%@test:INTEGER` - b. Adding a Matlab test code that provides a pass/fail indicator `T` that takes on `true` if the test passed. - c. Closing the test with `%@eof:INTEGER` +1. Add the particular tests at the end of the file after a `return` by + 1. Starting a test with `%@test:INTEGER` + 2. Adding a Matlab test code that provides a pass/fail indicator `T` that takes on `true` if the test passed. + 3. Closing the test with `%@eof:INTEGER` where `INTEGER` denotes the number of the test. An example testing the correct functionality of mode-computations for a normal distribution is @@ -113,7 +113,7 @@ An example testing the correct functionality of mode-computations for a normal d ``` function m = compute_prior_mode(hyperparameters,shape) % --*-- Unitary tests --*-- -end +return %@test:1 % Normal density @@ -130,3 +130,4 @@ end T = all(t); %@eof:1 ``` +You can also put a unit test after the closing `end`, but in this case you will need to preface each line with `%$`. See e.g. https://git.dynare.org/Dynare/dseries/-/commit/be4a4d39c125b92ee84ef876d86e6ec947c522b8